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?

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

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

  1. 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

  2. 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

  3. Good Day,

    Great video, im wondering if you can help i have to do the above over 260 times is there a way to make this pain free instead of copying the code to every button?

  4. Please Kindly help me with a complete tutorial on how to grade students using excel vba with form.
    Thank you.
    Student Name Score/Mark Grade Remark
    Ama Yeboah 50% D Credit
    Augustine Dickson 80% A Excellent
    John Samson 34% F Fail
    Delight Amuzu 70% B Very Good
    Mark Nuworsu 61% C Good
    Agness Zowornu 45% E Pass

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.