excelnut1954 wrote:
'******** this is the part showing the error, in the rngFound part.
*******
'******** I thought I could use rngFound to identify each record in
the range. ******
For Each rngFound In rngToSearch .
RecordsFound = RecordsFound + 1
Next rngFound
This part isn't doing what you think. rngFound pointed to the cell returned
by the Find method, but using it in the For Each destory's that pointer and
points it to J1 (on the first loop).
Since you don't use the After argument in the Find method, Find is always
going to return the first one it finds. If you display "Record x of y", x
will always be 1. To find y, you need to use FindNext until it loops back
to the first one and count them along the way. All this should be in the
Else part of your If rngFound Is Nothing block.
If you want the user to be able to loop through all the POs, you'll need
another variable to hold all the cells that are found.
Else
strFirst = rngFound.Address
Set rngAllFound = rngFound
Do
Set rngFound = rngToSearch.FindNext(rngFound)
Set rngAllFound = Union(rngAllFound, rngFound)
Loop Until rngFound.Address = strFirst
RecordsFound = rngAllFound.Cells.Count
Now rngAllFound will be a range of cells with that PO number and rngFound
will be pointing to the first one it finds.
If you can clarify what you're doing, I may be able to give you more
specific help. You can see an example of the Find method here
http://www.dailydoseofexcel.com/arch...e-find-method/
--
Dick Kusleika
MS MVP - Excel
www.dailydoseofexcel.com