Suppose I have: "Apple" "OX" "Mule" "Apple" "Soap" "OX" "OX
" in Range("A1:A7") and I nominate "OX" to be tracked down in the
range using FIND/FINDNEXT loop. My understanding of the Find/findnext
construct is that at the first pass of loop, FIND will hit a blank at
"Apple" but will proceed and locate a match in "OX". Then the FINDNEXT
command takes over, again seeking a match for "OX" which will only be
met 4 passes further down at A6.
In all this, where do we fit *the data that would make FindNext work
is erased*. May be I am being obtuse, Dick.
No, I just probably explained it poorly. Assume you have data in a grid
like
1 2 5 7 8 5
10 3 6 9 2 8
1 5 9 1 1 6
Further assume that every time there's a 1 in column A, any five that exists
in that row needs to be changed to 50. It would be nice to write code like
this
Set rFound1 = Range("A1:A3").Cells.Find(1)
Do Until rFound1 Is Nothing Or 'Some test to catch wrap around
Set rFound2 = rFound1.EntireRow.Cells.Find(5)
Do Until rFound2 Is Nothing
rFound2.Value = 50
Set rFound2 = rFound1.EntireRow.FindNext(rFound2)
Loop
Set rFound1 = Range("A1:A3").FindNext(rFound1) '[1]
Loop
[1] This line won't work because the original Find's information has been
lost. VBA won't know to search for '1' anymore because another Find has
been executed in the interim. In fact, it will search for '5' in A1:A3 and
the '5' in B3 will never get changed to 50.
--
Dick Kusleika
Excel MVP
Daily Dose of Excel
www.dicks-blog.com