VBA & Macro Problems

How to Use Application.Caller for Excel Buttons on Multiple Worksheets in WPS Spreadsheets

Steve KSteve K Nov 13, 2026 869 views

Question details

The user needs a VBA macro to identify the specific button shape that launched it when the same button is copied across multiple worksheets, instead of depending on a fixed shape name or index.

How to Use Application.Caller for Excel Buttons on Multiple Worksheets in WPS Spreadsheets
Product
WPS Spreadsheets
Device & OS
not provided
Scenario
The user has copied macro buttons to multiple worksheets and wants one macro to update the clicked button's formatting or behavior on any sheet.
Observed behavior
Using a fixed shape name or index fails because copied buttons receive different names or positions, so the macro cannot reliably find the selected button.
Before you start

Open the workbook in WPS Spreadsheets and make sure the Developer tab is visible: right-click the ribbon, choose Customize Ribbon, and enable Developer if needed. Save a macro-enabled copy as .xlsm so the VBA changes are retained.

Solution 1Recommended

Reference the Clicked Button with Application.Caller

Use this method when one macro must work with identical buttons copied to different worksheets without changing the code for each sheet.

Application.Caller returns the name of the shape that started the macro. Assign that name to a Shape variable through ActiveSheet.Shapes so you can alter the exact button the user clicked, rather than a hard-coded shape name or index.

1
Open the VBA editor

In WPS Spreadsheets, click Developer > Visual Basic or press Alt+F11, then open the module that contains the macro.

2
Remove fixed shape references

Delete fixed names such as Shapes("Button 1") or shape index references from the macro.

3
Assign the calling shape

Declare a Shape variable and set it to the calling shape with Dim btn As Shape and Set btn = ActiveSheet.Shapes(Application.Caller).

4
Update the selected button formatting

Use btn.Fill.ForeColor.RGB = RGB(0, 176, 80), or another Fill property, to change the clicked button's color.

5
Save and test on multiple worksheets

Save the macro-enabled workbook, click copies of the button on different worksheets, and confirm only the clicked button changes.

Reference the Clicked Button with Application.Caller
Macro now follows the clicked button: The macro uses the calling shape instead of a fixed sheet, shape name, or index.
WPS Spreadsheets VBA Macro

Use Application.Caller in WPS Spreadsheets to Manage Copied Macro Buttons

WPS Spreadsheets supports VBA macros, so you can use Application.Caller to identify the exact button shape that triggered the macro and update it across multiple worksheets without fixed names or indexes.

  1. 1. Open the VBA editor: In WPS Spreadsheets, click the Developer tab and select Visual Basic, or press Alt+F11.
  2. 2. Open the macro module: In the Project Explorer, find your workbook and open the module where the macro is stored.
  3. 3. Add Application.Caller code: Create a Shape variable and set it to ActiveSheet.Shapes(Application.Caller).
  4. 4. Modify the button fill: Change the shape's Fill properties, such as btn.Fill.ForeColor.RGB = RGB(0, 176, 80).
  5. 5. Save and run the macro: Save the file as a macro-enabled workbook (.xlsm) and click each copied button to test.
Lets one macro update copied buttons on any worksheet without manual renaming.Maintains compatibility with Microsoft Excel .xlsm and .xls macro-enabled files.Provides a familiar VBA editor and shape-property model for Excel macro users.Runs as a free, lightweight alternative to Microsoft Excel for everyday macro tasks.
microsoft office alternative - wps office

Frequently Asked Questions

What exactly does Application.Caller return when a shape button runs a macro?

It returns the name of the shape that called the macro, so ActiveSheet.Shapes(Application.Caller) gives you that exact button object.

Does Application.Caller work in WPS Spreadsheets?

Yes. In WPS Spreadsheets, open the VBA editor from Developer > Visual Basic and use Application.Caller in a standard module assigned to a shape.

Why does my macro fail after I copy buttons to another worksheet?

Copied buttons often get new shape names or indexes, so fixed references like Shapes("Button 1") point to the wrong shape or nothing. Application.Caller avoids that problem.

Can I use Application.Caller with ActiveX command buttons?

Application.Caller is mainly used with Form control buttons or shapes assigned to macros. ActiveX command buttons are handled through their own event procedures.