Free Websites, Free Hosting, Free Software and Lots of Other Free Stuff
26 Aug
Most people’s first knowledge of Excel VBA (or Visual Basic for Applications) is recording a macro. As a user performs a series of operations (e.g. opening a workbook activating a particular worksheet, copying some data, etc) Excel will faithfully record each step and create the necessary VBA code. Each time the user runs the macro, these steps are replayed exactly as they were originally recorded.
Recording macros is excellent for really simple operations such as producing a simple report. However, there are definite limitations to this approach. Firstly, because Excel plays back the steps just as they were originally performed by the user, recorded macros are notoriously slow to play back.
Also, recorded macros will only run normally under the conditions in which they were originally recorded. Thus, for example, if a particular worksheet has to be active at a certain point and it is not active when the macro is played back, the user will get an error.
This means, effectively, that recorded macros can only really be used by the person who recorded them. They cannot be distributed to one’s 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.
True, there is a bit of a steep learning curve for those users who have done little or no programming. This is one reason why we run a five day intensive Excel VBA training course for new users. We find that it gives everyone a chance to gain confidence and familiarity with this challenging environment.
Next we teach them the syntax and structure of VBA. How to use variables to store both data and references to Excel objects, how to create logical and iterative structures and how to allow the user of a macro to make choices.
Getting some training on Excel VBA is always worth the effort. It can take the productivity of an Excel user to a new level very rapidly. Monthly procedures and reports which used to take long hours can suddenly be accomplished with astounding ease and lightening speed.
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.
Leave a reply
You must be logged in to post a comment.