How to increase decrease value of worksheet cell automatically

I need some Excel VBA help. I have a simple spreadsheet with a number in cell D2. I want to move a number up and down in value by pressing a button. The value of D2 is set to 1. Now I wish to press a button so that it becomes 2, 3 4, 5, etc. on every click. I would like to click on another button and make the value less by one. So if the value is 5 it becomes 4 on click and so on. I’ve searched everywhere but couldn’t find a solution. Can you help me please?
Evan

You can increase or decrease the worksheet cell value by using appropriately coded command buttons as shown in the MS Excel training video below:


The macro code for the ‘add’ and ‘minus’ buttons is given below:

Private Sub CommandButton1_Click()
Range(“D2”).Value = Range(“D2”).Value + 1
End Sub

Private Sub CommandButton2_Click()
Range(“D2”).Value = Range(“D2”).Value – 1
End Sub

2 thoughts on “How to increase decrease value of worksheet cell automatically

  1. krishna

    hi Sir

    hope you are well 🙂

    add a spin button in worksheet and double click on that to go to VB Editor window.
    below is the code for increase or decrease value in a cell

    Private Sub SpinButton1_SpinDown()

    Cells(1, 1) = Cells(1, 1) – 1

    End Sub

    Private Sub SpinButton1_SpinUp()

    Cells(1, 1) = Cells(1, 1) + 1

    End Sub

    Reply
  2. krishna

    i think i am giving code for very old video and it might help a little bit to others who see this video for learning

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *