Thread: Loop
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein \(MVP - VB\)[_1297_] Rick Rothstein \(MVP - VB\)[_1297_] is offline
external usenet poster
 
Posts: 1
Default Loop

Just to make a point... it took 1 hour 6 minutes for you to get an answer to
your question and another 34 minutes after that for you to see that answer.
You could have gotten an instaneous answer to your question if you had
placed your cursor on the word FindNext in your code and pressed F1 to evoke
Help for it... the Help file that would have come up for this method
explains the problem you raised in its Remarks section and gives a code
example on how to get around the problem.

Rick


"ranswert" wrote in message
...
Thanks I'll give that a try

"Jim Rech" wrote:

Will this get in a continual loop


Looks like it. What you want to do with the Find method is stop when
you're
back to the first hit, since Excel will just keep finding the same cells.
So get the address of the first hit and then break out of the loop if a =
linkno or the address of xcell = the address of the first hit.

--
Jim
"ranswert" wrote in message
...
| Will this get in a continual loop if "a" never equals "linkno"?
|
| With rng
| Set xcell = .find(what:=drwno, LookIn:=xlValues,
| LookAt:=xlWhole, _
| SearchOrder:=xlByColumns)
| a = xcell.Offset(0, 10).Value
| MsgBox ("a = " & a)
| If a < linkno Then
| Do
| Set xcell = .FindNext(xcell)
| a = xcell.Offset(0, 10).Value
| Loop While a < linkno
| End If
| End With
| Thanks