How to Fix an Excel Macro Button That Does Not Launch Solver
Question details
The user's Excel VBA macro successfully runs Solver from the Visual Basic editor but fails to execute when triggered via a worksheet button.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Attempting to run a macro that automates the Solver add-in by clicking a button located on the spreadsheet.
- Observed behavior
- The macro executes perfectly within the VBA editor environment, but clicking the worksheet button (often an ActiveX control) fails to launch Solver.
Ensure that the Solver add-in is properly enabled in your Excel Options and that you have enabled macros in your Trust Center settings.
Replace the ActiveX Control with a Form Control Button
ActiveX buttons can sometimes restrict macro execution for add-ins like Solver due to focus and security issues. Replacing it with a standard Form Control button is the most reliable fix.
ActiveX controls interact differently with the Excel application compared to standard Form Controls. When an ActiveX button is clicked, it can retain focus and prevent the Solver add-in dialog or execution process from initializing properly. Swapping it for a Form Control button ensures smooth execution.
Enable 'Design Mode' on the Developer tab, select the problematic ActiveX button on your worksheet, and press the Delete key.
On the Developer tab, click 'Insert'. Under the 'Form Controls' section (usually the top section), select the 'Button (Form Control)' icon.
Click and drag on the worksheet to draw the new button. The 'Assign Macro' dialog box will immediately pop up. Select your Solver macro procedure from the list and click 'OK'.
Click anywhere on a blank cell to deselect the button, then click the new button to verify that it successfully launches Solver.

Looking for a Smoother Spreadsheet Experience? Try WPS Office
If you are tired of dealing with ActiveX control glitches and complex macro troubleshooting in Microsoft Excel, consider switching to WPS Office. It provides a highly compatible, lightweight, and free alternative with excellent spreadsheet capabilities.
- 1. Download WPS Office: Visit the official WPS Office website and download the installer for your operating system.
- 2. Install and Launch: Run the installation file, follow the prompts, and open WPS Spreadsheets.
- 3. Open Your Spreadsheets: Load your existing spreadsheets seamlessly and enjoy a stable, user-friendly data analysis environment.

Frequently Asked Questions
Why does my macro work perfectly in the VBA editor but fail from a button?
This usually happens when the button is an ActiveX control. ActiveX controls can hold the application focus, which prevents certain add-ins like Solver from running correctly. Standard Form Controls do not have this issue.
How do I make sure the Solver add-in is enabled?
Go to File > Options > Add-ins. At the bottom of the window, ensure 'Excel Add-ins' is selected in the Manage dropdown and click 'Go'. Check the box next to 'Solver Add-in' and click 'OK'.
Do I need to do anything inside the VBA editor for Solver to work?
Yes. To control Solver via VBA, you must establish a reference to it. Open the Visual Basic Editor, click on Tools > References, and check the box next to 'Solver'. If it is not in the list, click 'Browse' and locate the solver.xlam file.




