You are making the job hard for yourself. You only need to keep track o
the current data row. This principle follows for adding new and deletin
records. Here is some basic code to go into a userform :-
Code
-------------------
'- general declaration
Dim CurrentRow As Long
'----------------------------------
'-initialise when form opened
Private Sub UserForm_Initialize()
CurrentRow = 1
Update_Form
End Sub
'-----------------------------------
'- next record button
Private Sub CommandButton1_Click()
CurrentRow = CurrentRow + 1
Update_Form
End Sub
'---------------------------------
'- previous record button
Private Sub CommandButton2_Click()
If CurrentRow 2 Then ' row 1 has headings
Set CurrentRow = CurrentRow - 1
Update_Form
Else
MsgBox ("Top of table")
End If
End Sub
'--------------------------------
'- common use subroutine
Sub Update_Form()
TextBox1.Value = Worksheets("Data").Cells(CurrentRow, 1).Value
TextBox2.Value = Worksheets("Data").Cells(CurrentRow, 2).Value
End Sub
'----------------------------------
-------------------
--
Brian
-----------------------------------------------------------------------
BrianB's Profile:
http://www.excelforum.com/member.php...tinfo&userid=5
View this thread:
http://www.excelforum.com/showthread.php?threadid=27560