I am writing a macro that runs through a Word document and highlights all the values that is contained in my cell range in Excel. I have used the Find
function which works fine until I add the argument IgnoreSpace:= True
, which I don't understand why it's resulting in error. Appreciate any help.
Sub Highlight() Dim lrow As Long lrow = Sheet1.Range("A" & Rows.Count).End(xlUp).Row Dim i As Long Dim myRange As Object Dim FindText As Object Set myRange = ActiveDocument.Content For i = 1 To lrow Step 1 myRange.Find.Execute FindText:=Sheet1.Range("A" & i).Value, MatchCase:=False, IgnoreSpace:=True, Forward:=True, MatchWholeWord:=True If myRange.Find.Found = True Then myRange.HighlightColorIndex = wdYellow Next iEnd Sub