Everyday Computing Advanced Computing The Internet At Home Health, Mind & Body Making & Managing Money Sports & Leisure Travel Beyond The Classroom
Handheld Computing
Hardware
Money Management Software
Multimedia
Office Productivity Software
Operating Systems
Moms, Dads, and Grads -- Win $500!
Excel 2007 VBA Programming For Dummies
Speeding Up Your VBA Code in Excel
Adapted From: Excel 2007 VBA Programming For Dummies

For most short Excel macros, especially when you’re just starting to learn VBA coding, the code seems to execute instantaneously. But as the code you creates gets longer, manipulates more variables, and stores more values, it requires more of your computer’s calculating powder, which can slow down the execution. Here are a few tips to help you speed up your VBA code in Excel:

  • Make sure to declare all your variables as a specific data type.
  • If you reference an object (such as a range) more than once, create an object variable by using the Set keyword.
  • Use the With-End With construct whenever possible.
  • If your macro writes data to a worksheet and you have lots of complex formulas, set the calculation mode to Manual while the macro runs. (But make sure you do a calculation when you need to use the results!)
  • If your macro writes information to a worksheet, turn off screen updating by using Application.ScreenUpdating = False.

Don’t forget to reinstate these last two settings to their starting values when your macro is finished.


To find out how to have Dummies eTips delivered to your e-mail inbox every week, visit the Dummies eTip Sign-Up Page.
Related Articles
Saving a Static Web Page in Excel 2002
Creating Interactive Web Pages in Excel
Reorganizing an Excel Worksheet
Customizing the AutoFilter Settings in Excel
Creating an Area Chart in Excel
Related Titles
Excel 2000 For Windows For Dummies
Excel 2000 for Windows For Dummies: Quick Reference
Excel 2002 For Dummies
Excel 2002 for Dummies: Quick Reference
Excel 2003 Power Programming with VBA