Change Cell Value Using Toggle Button in Excel: 6 Suitable Examples

Method 1 – Increase Cell Value by Toggle Button

Steps:

  • Insert a toggle button from the drop-down arrow of the Insert option of the Controls group, located in the Developer tab.

Choose ToggleButton option to insert toggle button

  • Rename the toggle button according to your desire. We keep the toggle button name as $50 Salary Increase.

Inserted toggle button to change cell value

  • Double-click on the toggle button to open the Visual Basic Editor box.

  • Write the following VBA code in that empty box.
Private Sub ToggleButton1_Click()
Dim i As Integer
    For i = 5 To 14
        Cells(i, 3).Value = Cells(i, 3).Value + 50
    Next i
End Sub
  • Press ‘Ctrl+S’ to save the code.
  • Close the Editor box.
  • Click once on the $50 Salary Increase toggle button, and you will notice each cell value will increase by $50 within a second.

Increase Cell Value by Toggle Button to Change Cell Value by Toggle Button

Breakdown of the VBA Code

Dim i As Integer

Declare an integer variable which is i.

For i = 5 To 14
    Cells(i, 3).Value = Cells(i, 3).Value + 50
Next i

Apply a For loop to add 50 with the values of every cell from rows 5 to 14.


Method 2 – Decrease Cell Value Through Toggle Button

Steps:

  • Insert a toggle button from the drop-down arrow of the Insert option of the Controls group, located in the Developer tab.

Choose ToggleButton option to insert toggle button

  • Rename the toggle button according to your desire. We keep the toggle button name as Decrease Value.

Using decrease value toggle button to change cell value

  • Double-click on the toggle button to open the Visual Basic Editor box.

  • Write the following VBA code in that empty box.
Private Sub ToggleButton1_Click()
Dim i As Integer
    For i = 5 To 14
        Cells(i, 4).Value = Cells(i, 3).Value - 50
    Next i
End Sub
  • Press ‘Ctrl+S’ to save the code.
  • Close the Editor box.
  • Click once on the Decrease Value toggle button, and you will notice each cell value of column D replaced with the new value.

Decrease Cell Value Through Toggle Button to Change Cell Value by Toggle Button

Breakdown of the VBA Code

Dim i As Integer

Declare an integer variable which is i

For i = 5 To 14
        Cells(i, 4).Value = Cells(i, 3).Value - 50
Next i

Apply a For loop to replace all values of column 4 with column 3 after deducting 50 from the existing value.


Method 3 – Add and Change Cell Value at Same Time

Steps:

  • Insert a toggle button from the drop-down arrow of the Insert option of the Controls group, located in the Developer tab.

Choose ToggleButton option to insert toggle button

  • Rename the toggle button according to your desire. We keep the toggle button name as Add $50.

Insert Add $50 toggle button to change cell value

  • Double-click on the toggle button to open the Visual Basic Editor box.

  • Write down the following VBA code in that empty box.
Private Sub ToggleButton1_Click()
Dim i As Integer
    For i = 5 To 14
        Cells(i, 4).Value = Cells(i, 3).Value + 50
    Next i
End Sub
  • Press ‘Ctrl+S’ to save the code.
  • Close the Editor box.
  • Click once on the Add $50 toggle button, and you will get the result.

Add and Change Cell Value at Same Time to Change Cell Value by Toggle Button

Breakdown of the VBA Code

Dim i As Integer

Declare an integer variable which is i

For i = 5 To 14
        Cells(i, 4).Value = Cells(i, 3).Value + 50
    Next i

Apply a For loop to replace all values of column 4 with column 3 after adding 50 with each cell value.


Method 4 – Multiplying a Cell Value Through Toggle Button

Steps:

  • Insert a toggle button from the drop-down arrow of the Insert option of the Controls group, located in the Developer tab.

Choose ToggleButton option to insert toggle button

  • Rename the toggle button according to your desire. We keep the toggle button name as the 10% Increment.

Insert 10% Increment toggle button to change the cell value

  • Double-click on the toggle button to open the Visual Basic Editor box.

  • Write down the following VBA code in that empty box.
Private Sub ToggleButton1_Click()
Dim i As Integer
    For i = 5 To 14
        Cells(i, 4).Value = Cells(i, 3).Value * 1.1
    Next i
End Sub
  • Press ‘Ctrl+S’ to save the code.
  • Close the Editor box.
  • Click once on the 10% Increment toggle button, and you will get the result.

Multiplying a Cell Value Through Toggle Button to Change Cell Value by Toggle Button

Breakdown of the VBA Code

Dim i As Integer

Declare an integer variable which is i

For i = 5 To 14
        Cells(i, 4).Value = Cells(i, 3).Value * 1.1
Next i

Apply a For loop to replace all values of column 4 with column 3 after multiplying 10% increment with every value.


Method 5 – Change Cell Value Based on Criteria

Steps:

  • Insert a toggle button from the drop-down arrow of the Insert option of the Controls group, located in the Developer tab.

Choose ToggleButton option to insert toggle button

  • Rename the toggle button according to your desire. We keep the toggle button name as the Apply Criteria.

Insert Apply Criteria toggle button to change cell value

  • Double-click on the toggle button to open the Visual Basic Editor box.

  • Write the following VBA code in that empty box.
Private Sub ToggleButton1_Click()
Dim i As Integer
    For i = 5 To 14
        If Cells(i, 3).Value = 0 Then
            Cells(i, 3).Value = Cells(i, 3).Value + 1000
        Else
            Cells(i, 3).Value = Cells(i, 3).Value + 100
        End If
    Next i
End Sub
  • Press ‘Ctrl+S’ to save the code.
  • Close the Editor box.
  • Click once on the Apply Criteria toggle button, and you will figure out the final result.

Change Cell Value Based on Criteria to Change Cell Value by Toggle Button

Breakdown of the VBA Code

Dim i As Integer

Declare an integer variable which is i.

For i = 5 To 14
        If Cells(i, 3).Value = 0 Then
            Cells(i, 3).Value = Cells(i, 3).Value + 1000
        Else
            Cells(i, 3).Value = Cells(i, 3).Value + 100
        End If
    Next i

Apply a For loop to replace all values of column 3. Moreover, inside the For loop, we use a conditional If argument to check whether the value is 0 or not, If the cell value is 0, we will get 1000. It will add 100 to the existing value.


Method 6 – Deleting Cell Value by Toggle Button

Steps:

  • Insert a toggle button from the drop-down arrow of the Insert option of the Controls group, located in the Developer tab.

Choose ToggleButton option to insert toggle button

  • Rename the toggle button according to your desire. We keep the toggle button name as the Delete Value.

Add Delete Value toggle button to change value

  • Double-click on the toggle button to open the Visual Basic Editor box.

  • Write the following VBA code in that empty box.
Private Sub ToggleButton1_Click()
ActiveCell.ClearContents
End Sub
  • Press ‘Ctrl+S’ to save the code.
  • Close the Editor box.
  • Select a cell and click once on the Delete Value toggle button.
  • You will see the value is removed from the cell.

Deleting Cell Value by Toggle Button to Change Cell Value by Toggle Button


Download Practice Workbook

Download this practice workbook for practice while you are reading this article.

Get FREE Advanced Excel Exercises with Solutions!
Soumik Dutta
Soumik Dutta

Soumik Dutta, having earned a BSc in Naval Architecture & Engineering from Bangladesh University of Engineering and Technology, plays a key role as an Excel & VBA Content Developer at ExcelDemy. Driven by a profound passion for research and innovation, he actively immerses himself in Excel. In his role, Soumik not only skillfully addresses complex challenges but also demonstrates enthusiasm and expertise in gracefully navigating tough situations, underscoring his unwavering commitment to consistently deliver exceptional, high-quality content that... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo