I am having trouble with my PREV & NEXT command buttons on userform where it thinks the last row used is row 3. Row 3 is the starting row with data but is not the last row with dat. I suspect the problem lies within my Userform_initailize procedure but I cannot figure out the answer after very many hours & driving me crazy with all sorts of attempts. Here's my current code & can someone please help me:
Private Sub UserForm_Initialize()
lCurrentRow = 3
Range("a3").Select
If IsNull(ActiveCell.Offset(1, 0)) Or ActiveCell.Offset(1, 0) = "" Then
lLastRow = 3
Else: Selection.End(xlDown).Select
lLastRow = ActiveCell.Row
End If
ActiveCell.Select
End Sub
_____________________________
Private Sub cmdNext_Click()
If lLastRow = lCurrentRow Then
MsgBox "You have reached the last row."
Else
lCurrentRow = lCurrentRow + 1
End If
LoadRow
End Sub
_____________________________
Private Sub cmdPrev_Click()
If lCurrentRow > 3 Then
lCurrentRow = lCurrentRow - 1
LoadRow
Else
MsgBox "The first row is displayed."
End If
End Sub
Private Sub UserForm_Initialize()
lCurrentRow = 3
Range("a3").Select
If IsNull(ActiveCell.Offset(1, 0)) Or ActiveCell.Offset(1, 0) = "" Then
lLastRow = 3
Else: Selection.End(xlDown).Select
lLastRow = ActiveCell.Row
End If
ActiveCell.Select
End Sub
_____________________________
Private Sub cmdNext_Click()
If lLastRow = lCurrentRow Then
MsgBox "You have reached the last row."
Else
lCurrentRow = lCurrentRow + 1
End If
LoadRow
End Sub
_____________________________
Private Sub cmdPrev_Click()
If lCurrentRow > 3 Then
lCurrentRow = lCurrentRow - 1
LoadRow
Else
MsgBox "The first row is displayed."
End If
End Sub