How to Save VBA Code in Excel (3 Suitable Methods)

Get FREE Advanced Excel Exercises with Solutions!

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.

How to Save VBA Code in Excel

  • 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.

How to Save VBA Code in Excel

  • Finally, press the Save button

How to Save VBA Code in Excel

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.

How to Save VBA Code in Excel

  • 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.

from Visual Basic Editor

  • 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.

from Visual Basic Editor

Read More: Excel VBA: Save Workbook in Specific Folder (4 Suitable Examples)


Similar Readings


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.

Exporting as BAS Format

  • 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.

Exporting the VBA Code as BAS Format

  • 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

Osman Goni Ridwan
Osman Goni Ridwan

I am Ridwan, graduated from Naval Architecture and Marine Engineering Dept, BUET, currently residing in Dhaka, Bangladesh. And my passion is to grow up my skillsets with industry demands. My prime goal is to be a data analyst as I do love to solve problems and play with data.

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo