Hi,
I'm new to vba and apologise if mail is simple one.
I have a word document containing e.g. the following text
beer is great
cider makes you ill
I want to create a macro which after finding the word beer will highlight the entire line containing this word. I have done the easy part. Can anyone help with the 'highlighting to end of the line'.
Sub beer()
'
' beer Macro
'
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "beer"
.Replacement.Text = "beer"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.CorrectHangulEndings = True
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = False
.MatchFuzzy = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
ShowVisualBasicEditor = True
End Sub
Regards
RedBelly
I'm new to vba and apologise if mail is simple one.
I have a word document containing e.g. the following text
beer is great
cider makes you ill
I want to create a macro which after finding the word beer will highlight the entire line containing this word. I have done the easy part. Can anyone help with the 'highlighting to end of the line'.
Sub beer()
'
' beer Macro
'
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "beer"
.Replacement.Text = "beer"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.CorrectHangulEndings = True
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = False
.MatchFuzzy = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
ShowVisualBasicEditor = True
End Sub
Regards
RedBelly