I have a set of data in 3x columns: Name, Age, Job.
I have put together a userform where a user can use to find Names, Ages and Jobs, in 3x separate textboxes (TextBox1, TextBox2 and TextBox3). It starts right at the top, which is done by design, which works fine. I also have a 'next' button, where when a user would click next and it will go to the next item in the list.
So when the user clicks next, it should ideally go to row 3 data (row 1 = headers).
Code:
Private Sub CommandButton3_Click()
Dim AANo As String
Dim AANa As String
Dim AAEm As String
Dim NextLR As Long
NextLR = Sheets("AASD").Cells(Rows.count, "QH").End(xlUp).row
For i = 2 To NextLR
With Worksheets("AASD")
Name = .Range(i, 8).Value
Age = .Range(i, 9).Value
Job = .Range(i, 10).Value
End With
TextBox1.Value = Name
TextBox2.Value = Age
TextBox3.Value = Job
Next i
End Sub
This in theory should work, but it doesn't. I am not sure where I went wrong. Any advise where I went wrong?
Thanks
Modified code:
Private Sub CommandButton3_Click()
Dim AANo As String
Dim AANa As String
Dim AAEm As String
Dim NextLR As Long
Dim count As Long
NextLR = Sheets("AASD").Cells(Rows.count, "QH").End(xlUp).row
count = 2
For i = count To NextLR
With Worksheets("AASD")
AANo = .Range(i, 8).Value
AAName = .Range(i, 9).Value
AAEm = .Range(i, 10).Value
End With
TextBox1.Value = AANo
TextBox2.Value = AANa
TextBox3.Value = AAEm
count = count + 1
Exit For
Next i
End Sub