How can I make my VBA code run as fast as possible

Here are a few tips:

1 Make sure to declare all your variables as a specific data type. (Use Option Explicit in each module's Declarations section to force yourself to declare all variables.)

i If you reference an object (such as a range) more than once, create an object variable using the Set keyword.

i Use the With-End With construct whenever possible.

i 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.

i If your macro writes information to a worksheet, turn off screen updating by using Application.ScreenUpdating = False.

0 0

Post a comment