Use an Excel Macro to Increase or Decrease a Cell by One in WPS Spreadsheets
Question details
Create VBA macros that increase or decrease the value in cell D5 by one and assign them to buttons or other controls.

- Product
- WPS Spreadsheets
- Device & OS
- not provided
- Scenario
- The user has a workbook with a value in D5 and wants to change that value up or down by one through assignable button macros.
- Observed behavior
- After assigning the macros to controls, the increase button should add 1 to D5, and the decrease button should subtract 1 from D5.
Open the target workbook in WPS Spreadsheets, save it as a macro-enabled workbook (.xlsm), and make sure the Developer tab is enabled via File > Options > Customize Ribbon.
Create the Increase and Decrease VBA Macros and Assign Them to Buttons
Use this when you want a clickable button to add 1 to or subtract 1 from cell D5 in any WPS Spreadsheets workbook.
The macros below write the result directly back to D5, so the workbook does not need complex formulas or extra helper columns. Replace Range("D5") with another Range address if the target cell changes.
In WPS Spreadsheets, click the Developer tab and then click Visual Basic, or press Alt+F11.
In the Project Explorer pane, right-click the workbook project, choose Insert, and then choose Module.
In the new module, paste: Sub IncreaseValue() Range("D5").Value = Range("D5").Value + 1 End Sub Sub DecreaseValue() Range("D5").Value = Range("D5").Value - 1 End Sub
Close the editor, go to Developer > Insert > Button (Form Control), and draw the button over the worksheet.
In the Assign Macro dialog, select IncreaseValue and click OK. Repeat for DecreaseValue, then click the buttons to verify D5 changes by one.

Run the Macros Directly From the Macro Dialog for Quick Testing
Use this when you only need to test the macros without adding buttons to the worksheet.
Set Up Increase/Decrease Buttons in WPS Spreadsheets with VBA
WPS Spreadsheets can directly run VBA macros that increment or decrement a chosen cell, so you can add interactive controls without leaving the workbook. Save the file in Excel-compatible .xlsm format and open or share it with users who need macro-enabled controls.
- 1. Open developer tools: In WPS Spreadsheets, open your workbook and click the Developer tab.
- 2. Insert a module: Click Visual Basic, then Insert > Module.
- 3. Paste the IncreaseValue and DecreaseValue macros: Add one macro for Range("D5").Value + 1 and one for Range("D5").Value - 1.
- 4. Assign buttons: Use Developer > Insert > Button to draw two buttons and assign each macro.
- 5. Save as macro-enabled: Save the workbook as .xlsm so the buttons continue to work after reopening.

Frequently Asked Questions
Can I make the macro change the active cell instead of always using D5?
Yes. Replace Range("D5") with ActiveCell in both macros, or use a named range such as Range("MyCell").
Why does the button not run the macro in WPS Spreadsheets?
Check that the file is saved as .xlsm, the macro is assigned to the button, and macro security is not blocking VBA. In WPS Spreadsheets, look under Developer > Macro Security to allow the workbook’s macros.
Will these macros work when I open the workbook in Microsoft Excel?
Yes. WPS stores VBA in compatible .xlsm files, so the same IncreaseValue and DecreaseValue procedures run in Excel when macros are enabled.
How do I save a WPS workbook with macros?
Click File > Save As, choose Excel Macro-Enabled Workbook (.xlsm), select a location, and click Save.
Can I assign the macro to a shape instead of a form control button?
Yes. Right-click the shape and choose Assign Macro, then select IncreaseValue or DecreaseValue.




