VBA & Macro Problems

Fix Excel VBA Macro High CPU Usage When Started by a Button

Bushra ParveenBushra Parveen Nov 2, 2026 871 views

Question details

An Excel VBA macro consumes a disproportionately high amount of CPU (30-40%) when triggered by a worksheet button, but runs normally when executed directly from the VBA editor.

Fix Excel VBA Macro High CPU Usage When Started by a Button
Product
Excel
Device & OS
not provided
Scenario
Triggering a VBA script using a button within a worksheet.
Observed behavior
The macro causes significant CPU spikes compared to running it from the VBA editor, likely due to continuous UI focus switching or object selection conflicts.
Before you start

Before modifying your VBA code, save a backup copy of your Excel workbook (.xlsm) to prevent any accidental loss of your scripts or data.

Solution 1Recommended

Optimize VBA Code by Eliminating Select and ActiveCell

Directly referencing objects instead of selecting them prevents the UI from constantly updating focus, significantly reducing CPU load.

When a macro is triggered via a button, the button takes focus. If your code uses Select, Selection, or ActiveCell, Excel spends processing power constantly switching focus between the button and the selected cells or sheets. Referencing objects directly resolves this conflict.

1
Open the VBA Editor

Press Alt + F11 to open the VBA Editor and locate the module containing the macro assigned to your button.

2
Locate Select and Activate Methods

Scan your code for instances of '.Select', '.Activate', 'Selection', or 'ActiveCell'. Example of problematic code: Worksheets("A").Visible = True, Worksheets("A").Select.

3
Replace with Direct References

Modify the code to manipulate objects directly without selecting them. For example, instead of selecting a sheet to change a cell value, use Worksheets("A").Range("A1").Value = "Test".

4
Test the Macro

Save your changes, return to the worksheet, and click the button to verify that the CPU usage remains normal.

Optimize VBA Code by Eliminating Select and ActiveCell
Best Practice: Avoiding Select and ActiveCell not only reduces CPU usage but also makes your VBA code execute much faster and reduces the risk of runtime errors.
Efficient VBA Handling with WPS Office

Optimize Macros Easily in WPS Spreadsheet

WPS Office Spreadsheet provides excellent compatibility with Microsoft Excel macros and VBA. Its lightweight architecture ensures macros run smoothly without unnecessary CPU spikes, making it a perfect environment for executing and debugging your scripts.

  1. 1. Download and Install: Download and install WPS Office for free from the official website.
  2. 2. Open Your Workbook: Launch WPS Spreadsheet and open your .xlsm file containing the VBA macros.
  3. 3. Access the VBA Editor: Navigate to the Developer tab and click 'VBA Editor' to review and optimize your code.
  4. 4. Run the Macro: Assign your macros to buttons and execute them with improved performance and stability.
Fully compatible with Microsoft Excel (.xlsm) files and VBA scriptsLightweight design helps prevent high CPU usage during macro executionFamiliar user interface makes optimizing and editing code effortlessFree to use with advanced built-in developer tools
microsoft office alternative - wps office

Frequently Asked Questions

Why does using Select or ActiveCell cause high CPU usage in Excel VBA?

Using .Select or ActiveCell forces Excel to continually update the user interface by highlighting different parts of the screen. When a macro runs from a button, the system struggles for focus between the clicked button and the newly selected cells, resulting in a CPU spike. Referencing objects directly completely bypasses these UI updates.

What is the difference between a Form Control button and an ActiveX CommandButton?

ActiveX CommandButtons offer more extensive and customizable properties, such as TakeFocusOnClick, which can help mitigate CPU and focus issues. Form Control buttons are simpler to insert and use but lack these advanced property settings.

How can I check if my macro is causing the high CPU usage?

Open the Windows Task Manager (Ctrl + Shift + Esc) and monitor the Excel process. Run the macro directly from the VBA Editor, then run it from the button. If the CPU usage spikes significantly only when using the button, UI focus or selection methods in your code are the likely cause.