VBA to search each row of a word table column
I am trying to finish a macro that searches a selected Word column for user-entered text. I have a module that works, except that I need the search code to perform a 'MatchWholeWord' query and count the hits. The only way I know to do that is with a 'Do While .Execute' statement, but I'm having trouble getting it to search the column properly.
The code is have is in the the attached 'Count_Column_Text' file. I was using 'If InStr(oCell.Range.Text, TargetText) > 0 Then i = i + 1' (commented out in the attachment) and it found each occurrence of the search text. But it doesn't match the whole word, so if my search text phrase includes a word that exists by itself in several cells, those single words are included in the count.
Can someone advise how to do a proper match whole word query with a counter?
|