Most people’s first exposure to Excel VBA (Visual Basic for Applications) involves recording a macro. As the user performs a series of steps (for example opening a workbook going to a particular worksheet, copying some data, etc) Excel faithfully records each step by creating the necessary VBA code. Each time the user runs the macro, the steps are replayed exactly as they were recorded.
Recording macros is ideal for really simple tasks such as producing an extremely strait-forward report. However, there are distinct restrictions on this approach. Firstly, because Excel plays back the steps just as they were originally performed, recorded macros are often painfully slow.
Secondly, recorded macros will only run properly under the conditions in which they were originally recorded. For example, if a particular worksheet needs to be active at a certain point and it is not active when the macro is played back, an error will occur.
This means that recorded macros are only of use to the person who records them. They cannot be distributed to work colleagues.
One of the first things we do when we run an Excel VBA training course at our London training centre is to attempt to wean users off the recorder. We provide them with a good grasp of the Excel object model, a way of programmatically representing all of the elements that make up the Excel environment such as cells, workbook and worksheets.
Naturally, there is a bit of a steep learning curve for any users who have done little or no programming. For this reason, we run a five day crash-course in Excel VBA for fledgling macro programmers. We have found that this provides everyone with a chance to gain some degree of confidence with the challenging VBA environment.
After weaning users off the macro recorder, we explain to them the syntax and structure of VBA. They learn how to use variables to store both data and references to Excel objects, how to code logical and iterative structures and how to allow the person running a macro to choose between different options.
Despite its initial complexity, attending an Excel VBA training course is a good investment. It can greatly enhance the productivity of an Excel user. Monthly operations and reports which used to take hours can suddenly be streamlined and accomplished with astounding rapidity.
Getting trained on Excel VBA is a great way to wean oneself off the macro recorder. However, the recorder will still always have its uses. For example, when you are working with an Excel object or a series of steps with some degree of programmatic complexity, recording a few steps then looking at the code generated is a great way to learn new syntax.
If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!




