After making a macro in Excel, it is necessary to save the file. Also, you may want to save the macro module individually so you can use them in other files also. For this, you may want to learn how to save VBA code in Excel. But saving them is not as like saving a normal Excel file. So, in this article, I will show you some easy methods to save VBA code in Excel.
3 Simple Methods to Save VBA Code in Excel
1. Save a VBA Code with an Excel Workbook
You can save the full workbook with macros. But you have to use another format to keep the macros. For macro-enabled workbook, the format is .xlsm and the format for normal Excel workbook is .xlsx or .xls. So, to save an Excel file as a macro-enabled workbook follow the steps below:
📌 STEPS:
- Firstly, after working on the file, go to the File menu and select Save As option.
- Now, go to the target location to save and give the file a suitable name.
- Then, press on the drop-down menu of the type option.
- And, select the “Excel Macro-Enabled Workbook (*,xlsm)” option.
- Finally, press the Save button
Read More: VBA Code for Save Button in Excel (4 Variants)
2. Save a VBA Code from Visual Basic Editor
Alternatively, you can save the macro modules with the workbook from the Visual Basic Editor. Follow the steps below to save the VBA macro from the visual basic editor.
📌 STEPS:
- After the completion of the module, go to the top ribbon, and press on the File tab.
- Then, select the Save option. Alternatively, you can press Ctrl + S to save the file.
- As an outcome, a window named “Save As” will appear. Give a suitable name for the file in the File Name option.
- Then, press on the arrow in the Save as Type option to open the drop-down menu.
- And, from the drop-down menu, select the option “Excel Macro-Enabled Workbook (*,xlsm)”.
- Finally, press OK to save the module with the workbook in Macro-Enabled Excel format.
Read More: Excel VBA: Save Workbook in Specific Folder (4 Suitable Examples)
Similar Readings
- How to Open Word Document and Save As PDF or Docx with VBA Excel
- How to Undo Changes in Excel after Save and Close (2 Easy Methods)
- [Fix]: Microsoft Excel Cannot Open or Save Any More Documents Because There Is Not Enough Available Memory
- Save Excel as CSV with Double Quotes (3 Simplest Methods)
- Excel VBA: Create Invoice and Save PDF Format (with Quick Steps)
3. Export VBA Code as BAS Format
You can save the VBA code individually by exporting it to the .bas file. And by doing this, you can import it to another workbook to reuse the VBA code. So, follow the steps below.
📌 STEPS:
- After the completion of the module, go to the top ribbon.
- Then, Select File > Export File
- Alternatively, press the Ctrl + E keys on the keyboard to do the same thing.
- Then, the “Export File” window will appear.
- Now, give a suitable name for the module.
- You will see that the file format is “Basic Files”. Keep it as it is.
- Finally, press the OK button.
- From the same location, you can import the module to re-use.
Read More: Excel VBA Save as File Format (12 Suitable Examples)
Conclusion
In this article, I have shown 3 easy methods to save VBA code in Excel. I believe after reading this article, all confusion regarding this topic will be solved. So, I hope you found this article helpful. If you have any queries or recommendations, please share them in the comments section below. Don’t forget to check our website Exceldemy com for various Excel-related problems and solutions. Keep learning new methods and keep growing!
Related Articles
- Excel VBA: Choose Location and Save as PDF
- How to Undo a Save in Excel (4 Quick Methods)
- How to Save Multiple Excel Sheets as One File (5 Easy Methods)
- [Fixed!] Document Not Saved Excel Network Drive (5 Possible Solutions)
- How to Save Multiple Sheets in Excel to CSV (6 Easy Methods)
- How to Save One Sheet in Excel as PDF (3 Useful Ways)