The Macro Recorder
- 02:23
Introducing the macro recorder and how this can be used to record procedures.
Downloads
No associated resources to download.
Transcript
The easiest way to write Excel VBA code is to use the record macro function.
The macro recorder records all of the keystrokes and the functions we perform in the front end of Excel and converts this into a set of instructions in the VBA programming language.
To start the micro recorder, either click record macro from the ribbon or use the keyboard shortcut.
ALT L and R.
Give your macro an intuitive name.
There can be no spaces or special characters in the name, but we can get around this by using uppercase letters or the underscore.
We have the option of being able to run the macro by assigning it to a keyboard shortcut.
This may not be that useful in practice.
Many of these shortcut keyboard combinations are already used by Excel and only control and J.
Control and M and control and Q are available in Excel 2019.
If you assign a keyboard shortcut to your macro, this will overwrite any existing keyboard shortcut Whilst that macro is available, the macro can be stored either in this workbook, and this means we must have the file open for the macro to run, or we can store the macro in the personal macro workbook.
Think of this as a hidden workbook, which is loaded when you start Excel.
Whatever workbook that you are in, the macros in the personal macro workbook will always be available.
When saving your file, you will need to save the file with the Excel SM file extension, the macro enabled worksheet extension.
This will ensure that your macros are able to run.