View Single Post
 
Old 11-16-2014, 03:09 PM
Marrick13 Marrick13 is offline Windows XP Office 2010 32bit
Competent Performer
 
Join Date: Jun 2006
Posts: 103
Marrick13 will become famous soon enough
Default 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?
Attached Files
File Type: txt Count_Column_Text.txt (2.0 KB, 14 views)
Reply With Quote