0

I have been asked to set up a spreadsheet with buttons with six different values.

Every time a button is clicked then dropping value in cell.

I created six buttons (CommandButton1_Click, CommandButton2_Click, CommandButton3_Click..CommandButton6_Click)

Button one should have a value of 0.0
Button two should have a value of 0.1
Button three should have a value of 0.2
Button four should have a value of 0.3
Button five should have a value of 0.4
Button six should have a value of 0.5

When clicking on a button the right value is added in my spreadsheet

I need to have a feature in each button that when clicked, then go to next row.

All I have so far:

Private Sub CommandButton1_Click()
Range("b2") = Range("b2") + 0
End Sub

Private Sub CommandButton2_Click()
Range("b2") = Range("b2") + 1 / 10
End Sub

Private Sub CommandButton3_Click()
Range("b2") = Range("b2") + 2 / 10
End Sub

Private Sub CommandButton4_Click()
Range("b2") = Range("b2") + 3 / 10
End Sub

Private Sub CommandButton5_Click()
Range("b2") = Range("b2") + 4 / 10
End Sub

Private Sub CommandButton6_Click()
Range("b2") = Range("b2") + 5 / 10
End Sub

This only adds the value in cell b2.

I would like if all six buttons are pressed that my spreadsheet from B2 to B7 is valued: 0.0, 0.1, 0.2, 0.3, 0.4 & 0.5 and not just 1.5 in cell B2.

Community
  • 1
  • 1
Tommy4711
  • 1
  • 1
  • 1
    See [this question](https://stackoverflow.com/questions/11169445/error-in-finding-last-used-cell-in-excel-with-vba) for how to find the last row. – BigBen Nov 04 '19 at 12:59
  • It is not about finding the last row. It is adding a specific value from each CommandButton when clicked and then change to next row – Tommy4711 Nov 05 '19 at 14:19
  • Well you need to find the last row to change to the next row, right? That will fix your currently hard-coded `Range("B2")`. – BigBen Nov 05 '19 at 14:19
  • That is true. But then my low skills in VBA can´t combine the two steps I hope to get. 1) put in value in cell b2. 2) next click will put in value in b3 – Tommy4711 Nov 05 '19 at 14:35
  • This is how far I have made it... But it keep adding in B2 and not entering the following Rows It is my second line that course the issue, but I do not know how to solve it Private Sub CommandButton1_Click() Range("b2") = Range("b2") + 0 / 10 Range("b2").Select For Each cell In Range("b2:b11") If cell.Value = "" Then Exit For cell.Offset(1, 0).Select Next End Sub – Tommy4711 Nov 05 '19 at 18:53
  • Thank you for the support given – Tommy4711 Nov 05 '19 at 19:00

0 Answers0