![]() |
#1
|
|||
|
|||
![]()
Through searching for older post, i found this formula below, however, as for the StrFnd part, it appears that there are too many words i entered inside the string and it split the rest to the next column and that makes the remain words exclude from the string. How can i alternate the formula so i can include a large amount of words in String for search. Thanks
Sub HiLightList() Application.ScreenUpdating = False Dim StrFnd As String, Rng As Range, i As Long StrFnd = "dog,cat,pig,horse,man" For i = 0 To UBound(Split(StrFnd, ",")) Set Rng = ActiveDocument.Range With Rng.Find .ClearFormatting .Text = Split(StrFnd, ",")(i) .Replacement.ClearFormatting .Replacement.Highlight = True .Replacement.Text = "^&" .Forward = True .Wrap = wdFindContinue .Format = True .MatchCase = False .MatchWholeWord = True .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = True .Execute Replace:=wdReplaceAll End With Next Set Rng = Nothing Application.ScreenUpdating = True End Sub |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
AtaLoss | Word VBA | 37 | 09-22-2021 12:04 PM |
Find and highlight multiple words in a document | flatop | Word VBA | 3 | 04-16-2014 10:29 PM |
![]() |
redhin | Word VBA | 5 | 03-05-2013 05:42 AM |
![]() |
RBLampert | Word VBA | 13 | 10-23-2012 04:45 PM |
find - reading highlight - highlight all / highlight doesn't stick when saved | bobk544 | Word | 3 | 04-15-2009 03:31 PM |