"On Error" help required
Hi,
You need to terminate the normal sub before the error handling part by
mentionning Exit sub
Sub Macro1()
On Error GoTo Thyagaraj_Not_Found
.........
Exit sub
Thyagaraj_Not_Found :
........
End sub
Sub Macro1()
Dim Thyag
On Error GoTo Thyagaraj_Not_Found
Cells.Find(What:="Thyagaraj", After:=ActiveCell,
LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False).Activate
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End with
Exit Sub
Thyagaraj_Not_Found:
Thyag = MsgBox("Thyagaraj not found")
End Sub
Regards
JY
"Thyagaraj" wrote in message
oups.com...
Dear Friends,
In the code given below if there is no error then also the msg box is
displayed.
Any help please.
Sub Macro1()
Dim Thyag
On Error GoTo Thyagaraj_Not_Found
Cells.Find(What:="Thyagaraj", After:=ActiveCell,
LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False).Activate
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
Thyagaraj_Not_Found:
'Selection.Font.Bold = True
Thyag = MsgBox("Thyagaraj not found")
End With
End Sub
Thanks in Advance
Thyagaraj
|