below code searches for a specific term in a table (input by means of an inputbox) and shades the whole row grey where this term is located.
The code works fine but ...
... although I have indicated '.MatchWholeWord = True', more rows get shaded as required.
Example: Inputbox Input = "Set"
If a cell contains the term "My Set" or "Configuration-Set" or "Set Configuration", these rows also get shaded, but I only would like to get those rows shaded where the cell contents is just "Set" and nothing else.
Help is much appreciated. Thank you very much in advance.
Dim ht As Single
Dim strLen As Integer
Dim rng As Range
Dim strFind As String
Dim Index As Variant
Dim rngStory As Range
If MsgBox("Would you like to grey shade rows (20% grey) containing a specific term?" & vbCrLf & vbCrLf & _
"Shading for rows containing a specific text!", vbYesNo + vbQuestion, "Shade Rows featuring specific term: 20% Grey)") = vbNo Then
strFind = InputBox("Which term is to be searched?", "Indicate Term")
Set rngStory = ActiveDocument.StoryRanges(wdMainTextStory)
.Text = strFind
.MatchWholeWord = True
If .Find.Found Then
If rngStory.Information(wdWithInTable) Then
rngStory.rows(1).Shading.BackgroundPatternColor = RGB(235, 235, 235)
rngStory.ParagraphFormat.KeepWithNext = True
Loop Until Not (.Find.Found)