E
excelnut1954
The 3 subs below work fine except that when I try to FindPrevious, it
will step back to each record found, except for the original record,
the initial Find.
If there are 4 records found, I can look at all 4 via the FindNext. I
can also go back and forth to see records 2 thru 4. But, it will not
FindPrevious back to the original record.
Any suggestions?
Thanks,
J.O.
Module Declarations:
Public rngToSearch As Range
Public rngFound As Range
Public strFirst As String
Public FindPOVal As String
************************************************
Sub TestFind_POCurrent()
Worksheets("Official List").Activate
Set rngToSearch = Sheets("Official List").Columns("J")
Set rngFound = rngToSearch.Find(What:=FindPOVal, _
LookIn:=xlValues, _
LookAt:=xlWhole)
If rngFound Is Nothing Then
MsgBox "This record was not found."
Unload UserForm12
UserForm12.Show
Else
strFirst = rngFound.Address
rngFound.Select
Unload UserForm12
UserForm13.Show
End If
End Sub
*******************************************
Sub TestFindNext_POCurrent()
Worksheets("Official List").Activate
Dim rngCurrent As Range
Set rngCurrent = rngToSearch.FindNext(rngFound)
If rngCurrent.Address = strFirst Then
MsgBox "There are no other records with this PO/PL."
Else
Set rngFound = rngCurrent
rngFound.Select
Unload UserForm13
UserForm13.Show
End If
End Sub
**********************************************
Sub TestFindPrevious_POCurrent()
Worksheets("Official List").Activate
Dim rngCurrent As Range
Set rngCurrent = rngToSearch.FindPrevious(rngFound)
If rngCurrent.Address = strFirst Then
MsgBox "There are no other records with this PO/PL."
Else
Set rngFound = rngCurrent
rngFound.Select
Unload UserForm13
UserForm13.Show
End If
End Sub
will step back to each record found, except for the original record,
the initial Find.
If there are 4 records found, I can look at all 4 via the FindNext. I
can also go back and forth to see records 2 thru 4. But, it will not
FindPrevious back to the original record.
Any suggestions?
Thanks,
J.O.
Module Declarations:
Public rngToSearch As Range
Public rngFound As Range
Public strFirst As String
Public FindPOVal As String
************************************************
Sub TestFind_POCurrent()
Worksheets("Official List").Activate
Set rngToSearch = Sheets("Official List").Columns("J")
Set rngFound = rngToSearch.Find(What:=FindPOVal, _
LookIn:=xlValues, _
LookAt:=xlWhole)
If rngFound Is Nothing Then
MsgBox "This record was not found."
Unload UserForm12
UserForm12.Show
Else
strFirst = rngFound.Address
rngFound.Select
Unload UserForm12
UserForm13.Show
End If
End Sub
*******************************************
Sub TestFindNext_POCurrent()
Worksheets("Official List").Activate
Dim rngCurrent As Range
Set rngCurrent = rngToSearch.FindNext(rngFound)
If rngCurrent.Address = strFirst Then
MsgBox "There are no other records with this PO/PL."
Else
Set rngFound = rngCurrent
rngFound.Select
Unload UserForm13
UserForm13.Show
End If
End Sub
**********************************************
Sub TestFindPrevious_POCurrent()
Worksheets("Official List").Activate
Dim rngCurrent As Range
Set rngCurrent = rngToSearch.FindPrevious(rngFound)
If rngCurrent.Address = strFirst Then
MsgBox "There are no other records with this PO/PL."
Else
Set rngFound = rngCurrent
rngFound.Select
Unload UserForm13
UserForm13.Show
End If
End Sub