How to Speed Up Slow Excel VBA Macros by Avoiding Select and Activate
Question details
The user wants to improve the execution time of slow Excel VBA macros caused by inefficient worksheet and range selections.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Running VBA macros that involve repeatedly moving between worksheets, selecting ranges, copying, and pasting data.
- Observed behavior
- The macro execution takes unnecessarily long and becomes less reliable because of repeated activation and selection of worksheets and ranges.
Before modifying your code, save a backup copy of your macro-enabled workbook (.xlsm) to ensure you have a working version in case of errors.
Work Directly with Worksheet and Range Objects
Replace inefficient Select and Activate methods with direct references to Worksheet and Range objects to bypass interface updates and execute code much faster.
Using .Select or .Activate forces Excel to physically update the user interface and switch the active window context. By modifying ranges and moving data directly in the background, you bypass these visual updates, drastically cutting down execution time.
Press Alt + F11 on your keyboard to launch the Visual Basic for Applications Editor, then locate your macro module in the Project Explorer.
Search your code for instances of '.Select', '.Activate', 'Selection', and 'ActiveSheet'.
Rewrite separate copy and paste commands into a single statement. For example, replace 'Sheets("Sheet1").Select' and 'Range("A1:A4").Select' followed by copy/paste commands with 'Worksheets("Sheet1").Range("A1:A4").Copy Destination:=Worksheets("Sheet2").Range("D1")'.
Save your code and run the macro to verify that it executes successfully without visual stuttering and with reduced execution time.

Disable Screen Updating and Automatic Calculation
Use Application settings to temporarily suspend background processes that slow down macro execution.
Run and Optimize VBA Macros Seamlessly in WPS Spreadsheet
WPS Office offers robust, built-in support for VBA macros. You can edit, run, and optimize your VBA scripts directly within WPS Spreadsheet, utilizing direct object references to execute heavy workloads with exceptional speed.
- 1. Open your macro-enabled file: Launch WPS Spreadsheet and open your existing .xlsm or .xlsb workbook.
- 2. Access the Developer tab: Navigate to the Developer tab on the top ribbon menu.
- 3. Open the VBA Editor: Click on 'VBA Editor' to access your modules and apply the optimized direct range references.
- 4. Run your macro: Execute the streamlined macro directly from the editor or a custom workbook button to experience the performance gains.

Frequently Asked Questions
Why are .Select and .Activate so slow in VBA?
These methods force Excel to physically update the user interface and switch the active window context. This requires significantly more processing power and time compared to modifying the data in the background using direct object references.
Can I format cells directly without selecting them first?
Yes. You can apply formatting directly to a Range object. For example, use 'Range("A1:A10").Font.Bold = True' instead of selecting the range first and applying the format to 'Selection'.
Besides removing Select and Activate, how else can I speed up my VBA code?
You can disable unnecessary Excel features during macro execution. Set 'Application.ScreenUpdating = False', 'Application.Calculation = xlCalculationManual', and 'Application.EnableEvents = False' at the start of your macro, and restore them to their default values at the end.
What is the correct syntax to copy and paste without selecting?
You can perform a copy and paste in a single line using the Destination argument. The syntax is: SourceRange.Copy Destination:=TargetRange. For example: 'Worksheets("Sheet1").Range("A1").Copy Destination:=Worksheets("Sheet2").Range("B1")'.




