VBA & Macro Problems

Fix an Excel Macro That Fails from a Form Control Button

Steven ParkerSteven Parker Nov 25, 2026 869 views

Question details

The user needs an Excel macro to run correctly when launched from a Form Control button.

Fix an Excel Macro That Fails from a Form Control Button
Product
Microsoft Excel
Device & OS
not provided
Scenario
A macro runs from the Developer tab but is also assigned to a Form Control button on a worksheet.
Observed behavior
The macro fails when the button is clicked, even though it runs from the Developer tab. Recreating the button has not resolved the issue.
Before you start

Confirm that the worksheet button is a Form Control, not an ActiveX control. Open the workbook containing the macro and note any error message displayed when you click the button.

Solution 1Recommended

Verify the Form Control button's macro assignment

Use this check to make sure the button calls the intended macro in the intended workbook.

1
Open the assignment dialog

Right-click the Form Control button and select Assign Macro.

2
Check the macro

In the Assign Macro dialog, select the intended macro and check the workbook name if one is shown. Click OK to confirm the assignment.

3
Check the VBA procedure

On the Developer tab, select Visual Basic. In the Project pane, confirm that the assigned procedure is a public Sub with no required arguments in a standard module under Modules.

4
Test the button

Return to the worksheet and click the button. If it still fails, note the error and inspect the macro's workbook and worksheet references.

Verify the Form Control button's macro assignment
Free Microsoft Office alternative

Work with Excel Spreadsheets in WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for working with spreadsheets. Its support for common Microsoft Office formats helps you move everyday files between applications; test macro-dependent workbooks separately because VBA and Form Control behavior can differ.

Open and edit common Excel spreadsheet formats, including XLSXUse a familiar spreadsheet interface for everyday workbook tasksMove documents among compatible Microsoft Office formatsWork with a free, lightweight office suite
microsoft office alternative - wps office

Frequently Asked Questions

Why does my macro work from the Developer tab but not from the button?

The button may be assigned to a different macro or workbook, or the code may depend on the active sheet, selection, or caller. Right-click the button, select Assign Macro, and then inspect those references in Developer > Visual Basic.

Where should a macro assigned to a Form Control button be stored?

Place the assigned public Sub, with no required arguments, in a standard VBA module. Open Developer > Visual Basic and check the Modules folder in the Project pane.

How can I find the line that fails when I click the button?

In the VBA editor, set a breakpoint near the beginning of the assigned procedure with F9. Click the worksheet button, then use F8 to step through the code when execution pauses.

Will deleting and recreating the button fix the macro?

It can fix a problem with the control or its assignment, but it will not correct faulty VBA or workbook references. If the new button fails too, inspect and debug the macro.

What does ThisWorkbook refer to in VBA?

ThisWorkbook refers to the workbook containing the VBA code. Use it with an explicit worksheet and range, such as ThisWorkbook.Worksheets("Sheet1").Range("A1"), when that is the workbook you intend to access.