new to vba - go to end of sub
In this simple search for a word, I want to end the sub if the word is not in the document and not type Regards.
Sub Macro2()
'
' Macro2 Macro
'
'
Selection.Find.ClearFormatting
With Selection.Find.Font
.Bold = False
.Italic = False
End With
Selection.Find.Replacement.ClearFormatting
With Selection.Find.Replacement.Font
.Bold = False
.Italic = False
.Underline = wdUnderlineNone
End With
With Selection.Find
.Text = "test"
.Replacement.Text = "test replaced"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.EndKey Unit:=wdLine
Selection.TypeText Text:= _
"Regards,"
End Sub
|