Excel Guides

Creating a Plus Minus Button in Excel

Assuming you would like to create a button in Excel that will increment or decrement a number in a cell:

  1. Open the Visual Basic Editor by pressing Alt+F11 on your keyboard.
  2. In the Project Explorer window, double-click on the sheet where you want to place the button (Sheet1, for example).
  3. In the code window that appears, paste the following code:
Private Sub CommandButton1_Click()

    Dim oldValue As Double
    Dim newValue As Double

    'Get value from cell A1.
    oldValue = Range("A1").Value

    'Increment or decrement value in cell A1.
    If oldValue >= 0 Then
        newValue = oldValue + 1
    ElseIf oldValue < 0 Then
        newValue = oldValue - 1
    End If

    'Update cell A1 with new value.
    Range("A1").Value = newValue

  End Sub

This code will create a button that will appear on your worksheet. When clicked, it will increment or decrement the number in cell A1.

  1. To test the code, click the Run button on the toolbar.
  2. Click on the button you just created. It should increment or decrement the number in cell A1.







Creating a Plus Minus Button in Excel Using Macros


  1. Open Microsoft Excel and save your file as "PlusMinusButton.xlsm". This is important because we need to enable macros when we open this file later.
.

Move beyond 

Excel

Get started with Causal today.
Build models effortlessly, connect them directly to your data, and share them with interactive dashboards and beautiful visuals.