If search criteria is not found, then goto Repeat?

  • Thread starter Thread starter PCLIVE
  • Start date Start date
P

PCLIVE

I'm using a macro to search for an item. If the item is not found, then I
receive an error. How can I tell the macro to goto Repeat: if the search
criteria is not found?

This is my search code.

Selection.Find(What:=model, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=
_
xlNext, MatchCase:=False).Select

Thanks,
Paul
 
Hi Paul
try
Dim rng as range
on error resume next
set rng = Selection.Find(What:=model, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:= _
xlNext, MatchCase:=False)
on error goto 0
if not rng is nothing then
rng.select
end if
 
Thanks!

Frank Kabel said:
Hi Paul
try
Dim rng as range
on error resume next
set rng = Selection.Find(What:=model, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:= _
xlNext, MatchCase:=False)
on error goto 0
if not rng is nothing then
rng.select
end if
 
Back
Top