The Macro Recorder can be used to record simple macros.
Recording macros is very useful even if you are a very experienced programmer, although there are some limitations that you need to be aware of.
If you are relatively new to macros it is worth rehearsing your steps first before recording them.
This will help you to understand the code that is generated and to help make your code as efficient as possible.
When you record a macro Excel is basically recording the keystrokes, menu commands exactly as they are pressed.
After you have recorded a few single steps you can run the macro to perform the required task again and again.
Once you start the Macro Recorder all your keystrokes will be recorded and converted into VBA code.
Record your Macro
There is a button on the status bar that you can use to quickly record a macro.
The button on the status bar is just a shortcut to the "Record Macro" button on the Developer Tab.
The default location for your macro will be "This Workbook".
The name of your macro will default to "Macro1", "Macro2", etc.
The exact number will depend on the number of macros that have already been recorded in that specific workbook.
Macro names must begin with a letter and cannot resemble cell addresses (i.e. A1, B5, BT100 etc).
Macro names cannot include spaces although the underscore character can be used (e.g. "macroname_2").
You can also include numbers in your macro names.
It is sometimes easier to accept the default name and then change the name of the procedure later.
The shortcut key and description are optional.
You can stop recording at any time by using the Stop Recording button on the Developer tab.
Alternatively you can use the first button on the Status Bar.
It is very important to stop recording once you have finished otherwise Excel will carry on recording your keystrokes indefinitely.
Once you have finished recording you can cut and paste the code (via the clipboard) to different code modules.
Macro Recorder Limitations
There are a number of things that the macro recorder cannot generate code for:
*) Performing any loops or repeating statements (If, Do, While, Select etc)
*) Create or assign variables
*) Display any dialog boxes
*) Contain any error handling
*) Create functions (you can only create subroutines)
*) Code cannot be placed inside existing macros or subroutines.
*) Local settings or user options will be taken into account
© 2020 Better Solutions Limited. All Rights Reserved. © 2020 Better Solutions Limited TopPrevNext