VBA macros "deleted" after closing excel file

In Excel 2007 and above, files with macros have a different file extension.

Files without vba have the xlsx extension.

Files with macros need to be saved as a macro-enabled workbook with the xlsm extension.

For both file types there are also template variations, i.e. xltx and xltm respectively.

The default file format for a new file is xlsx, unless you change this setting in your Excel options.

If you include vba macros in the xlsx file and then try to save it, you will see a message that tells you that you cannot save macros in an xlsx file:

enter image description here

If you opt to ignore the message and save the file as a macro-free workbook, then please accept the fact that the macros will NOT be saved with the workbook.

You have seen the message. You have taken action NOT to save as a macro enabled file.

So, the macros are not saved with the file.

That's how it works.


Click "No": Click No

Select "Excel Macro Enabled Workbook" and click "Save": Select the Excel Macro Enabled Workbook,Click Save Option