Introduction to macros in Excel VBA

Last Updated on January 11, 2023 by token

1. What is macro in Excel

In this part of VBA course you will learn how to record and run macros under Excel program. As you already know Macros in Excel are programs which are running under Excel. Each of those programs are based on code, which were written in VB language. You use Excel macros usually to accelerate and automate activities which you can also do manually.

To fully use macros and VBA, you should first enable macros in your Excel program and have an active Developer tab. How to do it, we learned in the previous part of the course: Developer tab and macros enabling.

2. How to register a macro in Excel

The Developer card is already available in your Excel program. To register any sequence of actions, select the Macros icon in the Developer’s tab. You will display a window in which you can enter the name of your macro. You can also enter its description and shortcut key. Remember that the shortcut key can’t be already use in the standard shortcut keys available in Excel.

The macro can be saved in the current workbook or in the personal macro workbook. When you will by writing programs with this VBA Course, the right place to save macros code will be code window in the current workbook file saved using xlsm format. Xlsm format enable saving Excel workbooks with macro code. However, you want your macro to work with other worksheets and workbooks, it will be good reason to save the macro code in personal macro workbook . After recording the macro, you finish recording it in the developer tab by clicking Stop recording.

Excel VBA course - How to run and record macros in VBA Excel
Excel VBA course – How to run and record macros in VBA Excel

3. How to run a macro in Excel

To run any registered or written macro, first of all go to the Developer tab and click the Macros icon. You can start execute macros by clicking the Run button. In this window you can also check method, how the macro will be stored. In the current xlsm file or in the personal macro workbook. You can also run the macro from another opened Excel file.

Excel VBA course - Macros in VBA Excel
Excel VBA course – Macros in VBA Excel

As you see macros in Excel are very useful. Try to use it any time you need and anytime you want.

4. Useful Exercises (You can enter solution in a comment)

4.1. Using the macro recorder, register and run the following actions: Fill 3 cells with any numeric values. Color cells in black. Text in cells can by colored white. Then finish macro recording and run it on a new sheet. It is very easy.

More examples of Excel VBA basics can be found in the Excel VBA Course section and  Excel VBA Examples section. If you have any questions about this chapter, you can post them on the forum without logging in.

Leave a comment

Your email address will not be published. Required fields are marked *

%d bloggers like this: