Reputation: 11
I’m a VBA beginner, and I’m trying to get code for automatic numbering (1,2,3, etc) in to a cell (starting A2,A3,A4, etc) each time I submit the value rows of data. I tried looking on google, but all the examples and answers do not meet my requirement.
Currently, I have to edit and number it manually on my worksheet. If I deleted one of the row and update the list number manually. The next submitted data will continue on next empty row together with updating list number. The rest of the codes I got already.
Can you help me write code for Cells(erow, 1) for auto numbering. Thanks in advance. Here is my code:
Private Sub CB2_Click()
erow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
'Cells(erow, 1) ??? to get auto numbering starting from A2 (number 1,2,3,etc)
Cells(erow, 2) = TB1.Text
Cells(erow, 3) = TB2.Text
Cells(erow, 4) = TB3.Text
Cells(erow, 5) = TB4.Text
End Sub
Here is an image of my sheet:
And here is the userform:
Upvotes: 1
Views: 1208