"On Error" help required
add:
Exit Sub
see below what i modified your code:
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
exit sub
Thyagaraj_Not_Found:
'Selection.Font.Bold = True
Thyag = MsgBox("Thyagaraj not found")
End With
End Sub
"Thyagaraj" wrote:
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
|