Action on error

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

Hi.

The following code line searches for a value. When it
finds the value, further code will peform some other
actions.

My problem is when the string is not found. Is there a
way to use a conditional statement if the value is not
found?

Thanks,
Mike.

Cells.Find(What:=mydate, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
 
Hi Mike
try

Set OFound = Cells.Find(What:=mydate, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate

If Not oFound Is Nothing Then
oFound.activate
else
msgbox "not found"
End If
 
Frank:

Hi. Thanks for the reply.

I've tried it, but I get an error 91 on the set
statement. Do you know what I might be doing wrong?

Thanks,
Mike.
 
Back
Top