VBA & Macro Problems

Use an Excel Macro to Increase or Decrease a Cell by One in WPS Spreadsheets

Huma Ashraf ChHuma Ashraf Ch Nov 13, 2026 869 views

Question details

Create VBA macros that increase or decrease the value in cell D5 by one and assign them to buttons or other controls.

Use an Excel Macro to Increase or Decrease a Cell by One in WPS Spreadsheets
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.
Before you start

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.

Solution 1Recommended

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.

1
Open the Visual Basic editor

In WPS Spreadsheets, click the Developer tab and then click Visual Basic, or press Alt+F11.

2
Insert a standard module

In the Project Explorer pane, right-click the workbook project, choose Insert, and then choose Module.

3
Paste the increase and decrease procedures

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

4
Close the editor and insert a button

Close the editor, go to Developer > Insert > Button (Form Control), and draw the button over the worksheet.

5
Assign and test each macro

In the Assign Macro dialog, select IncreaseValue and click OK. Repeat for DecreaseValue, then click the buttons to verify D5 changes by one.

Create the Increase and Decrease VBA Macros and Assign Them to Buttons
Macros are assigned: The D5 value updates each time a button is clicked. Save the workbook as .xlsm to keep the macros.
WPS Spreadsheets macro workflow

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. 1. Open developer tools: In WPS Spreadsheets, open your workbook and click the Developer tab.
  2. 2. Insert a module: Click Visual Basic, then Insert > Module.
  3. 3. Paste the IncreaseValue and DecreaseValue macros: Add one macro for Range("D5").Value + 1 and one for Range("D5").Value - 1.
  4. 4. Assign buttons: Use Developer > Insert > Button to draw two buttons and assign each macro.
  5. 5. Save as macro-enabled: Save the workbook as .xlsm so the buttons continue to work after reopening.
Free WPS Office macro tooling for interactive workbook controlsWorks with Excel macro-enabled workbooks and .xlsm formatFamiliar VBA editor and Assign Macro workflowLightweight and easy-to-use alternative to Microsoft Excel
microsoft office alternative - wps office

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.