Taking Microsoft Excel 2003 VBA courses is the first step in adding new functionality to your spreadsheet projects. However it is only the beginning. Efficient and powerful macro programming takes experience and practice to achieve.
Here are a few tips to get recent, or not-so-recent, graduates of Microsoft Excel 2003 VBA courses pointed in the right direction.
Reduce Traffic Between Worksheets And Macros
Passing data back and forth from cells on the worksheet to your macros is a very slow process. Minimizing this communication greatly speeds up macro function. Some users, inspired to use techniques learned in Microsoft Excel 2003 VBA courses, use macros for simple calculations better handled by worksheet functions. This may be for readability with complex formulas. It is easier to understand a macro name than a huge equation.
The problem is the more readable macro solution is slower because of the communication overhead. In a small spreadsheet the speed difference is undetectable, but in a large project unnecessary macros can slow calculations down dramatically.
Another aspect of worksheet-macro traffic that is not always covered in Microsoft Excel 2003 VBA courses is the number of read/write events. It is much faster to read a block of a thousand cells than to read each cell individually. If a macro is acting on a large range of data, read the range in first before looping through the data rather than looping and reading a cell on each iteration.
Avoid Worksheet Functions In Macros
Graduates of Microsoft Excel 2003 VBA courses often find it is convenient to use existing worksheet functions, from simple Max formulas to advanced numerical functions, rather than re-inventing the wheel. However worksheet functions are slow.
A large part of this is the communication problem from the last section however sometimes the existing function is simply too complex for the macro designer's needs. Excel functions are designed to cover a wide range of possibilities so contain many logic tests and extra code to cover eventualities that your macro may never face.
Even built in macro functions discussed in Microsoft Excel 2003 VBA courses are often less efficient than simply doing it yourself. If there is a VBA function you use often, try speed tests to see if it would be faster to enter equations directly instead.
Provide Feedback
A watched spreadsheet never calculates. Sometimes your macros may be a marvel of efficient design, a prime example of skills learned in Microsoft Excel 2003 VBA courses, but users may perceive it as slow.
Any time the user is going to have to wait for more than a few seconds, provide some kind of feedback. An updating dialogue, a progress bar, or a status cell on the sheet are ways you can give the user some indication of how much remains to be done.
Don't worry about predicting the time left, but a percentage complete at least lets the user decide whether to wait or go get a cup of coffee.
You have permission to publish this article for free providing the "About the Author" box is included in its entirety.
Do not post/reprint this article in any site or publication that contains hate, violence, porn, warez, or supports illegal activity.
Do not use this article in violation of the US CAN-SPAM Act. If sent by email, this article must be delivered to opt-in subscribers only.
If you publish this article in a format that supports linking, please ensure that all URLs and email addresses are active links, without the rel='nofollow' tag.
Software Training London Ltd. owns this article. Please respect the author's copyright and above publication guidelines.
If you do not agree to these terms, please do not use this article.
Habib Bank AG Zurich Credit Analyst Jamshaid Akhtar
"The trainer was extremely enthusiastic and knowledgeable. I have definitely taken information from this"
NES Emily Brake
"Many thanks for this excellent training, which will be incredibly useful in our workplace"
FirstGroup Plc Data Analyst Dylan Dhinsa
"An all round good experience. Very informative, with an enthusiastic, helpful and patient trainer in Alan. The course material started off quite familiar, but I appreciated relearning the basics because of how much they reappeared throughout the course material. By the time I hit the end of the material, I felt more confident using PowerBI and specifically DAX (which had always confused me!). Would definitely recommend! P.S. a free lunch with complimentary coffee and biscuits are a great touch :)"