Hi,
I'm having a nightmare trying to find code to display (and edit if needed) the previous and next rows when using my userform.
The userform is simple, includes 7 textbox and 1 combobox. I've managed to get the userform to populate the data sheet on the first blank row but can't figure out how to 'navigate' the rows (to edit if there was any changes to be done etc)
I plan to use the data to fill in a protected viewer friendly worksheet/table, therefore the user can't simply go and edit the data directly.
Heres my code for the insert and cancel buttons;
I've already got a Next and Previous button set up on the form
Thanks in advance
I'm having a nightmare trying to find code to display (and edit if needed) the previous and next rows when using my userform.
The userform is simple, includes 7 textbox and 1 combobox. I've managed to get the userform to populate the data sheet on the first blank row but can't figure out how to 'navigate' the rows (to edit if there was any changes to be done etc)
I plan to use the data to fill in a protected viewer friendly worksheet/table, therefore the user can't simply go and edit the data directly.
Heres my code for the insert and cancel buttons;
Code:
Private Sub Insert_Click()
Dim CurrentRow As Long
Dim lastRow As Long
Dim ws As Worksheet
Set ws = Worksheets("SDP")
'find first empty row in database
CurrentRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
'copy the data to the database
With ws
.Cells(CurrentRow, 1).Value = Me.ComboBox1.Value
.Cells(CurrentRow, 2).Value = Me.TextBox1.Value
.Cells(CurrentRow, 3).Value = Me.TextBox2.Value
.Cells(CurrentRow, 4).Value = Me.TextBox3.Value
.Cells(CurrentRow, 5).Value = Me.TextBox4.Value
.Cells(CurrentRow, 6).Value = Me.TextBox5.Value
.Cells(CurrentRow, 7).Value = Me.TextBox6.Value
.Cells(CurrentRow, 8).Value = Me.TextBox7.Value
End With
End Sub
Private Sub Cancel_Click()
Unload Me
End Sub
I've already got a Next and Previous button set up on the form
Thanks in advance
Last edited: