I have an Excel form which reads data from each row of an 80-row worksheet and populates each cell into a textbox.
The code for the initial form is below.
Private Sub UserForm_Initialize()
txtbox_revri_idnum.Text = Worksheets("Risk&Issues").Range("A4").Value
txtbox_revri_projname.Text = Worksheets("Risk&Issues").Range("B4").Value
txtbox_revri_isrefnum.Text = Worksheets("Risk&Issues").Range("C4").Value
txtbox_revri_riskrefnum.Text = Worksheets("Risk&Issues").Range("D4").Value
...
txtbox_revri_projname.SetFocus
End Sub
Ideally, what I’d like to do is when the ‘next’ button is pressed, the next row (A5, B5, C5, D5…) is parsed into an array, and the Range is updated with the next row’s data. Conversely, the ‘previous’ button would go in the reverse direction (A3, B3, C3, D3…). Essentially, I’d like to navigate up and down the worksheet reviewing the entire row with each cell in a new textbox.
I’ve tried all sorts of combinations of VBA (baring in mind I’m new to VBA although do have some Java and PHP experience). The code I have for my ‘next’ button current has the code below.
Private Sub button_revri_next_Click()
txtbox_revri_idnum.Text = ActiveCell.Next.Text
...
End Sub
Thank you… I know you guys are way more smarter than me!
You can use
.Offsetto achieve what you want.TRIED AND TESTED
Similarly Previous Button