VBA How to Exclude Words from Macro

VorLag

Board Regular
Joined
May 13, 2013
Messages
205
This macro is actually in Word, but the functions shouldn't be too different. What I want to do is to highlight all words ending in -ing but excluding some words like bing (as in the cherry), thing, and being. I figured out how to get the macro to skip over 3 and 4 letter words, but I am not sure how to tweak this to also skip 5 letter words.

I would prefer to have a word list that the macro excludes.

How do you do that? Here is the macro so far:


Code:
Sub HighlightING()

Application.ScreenUpdating = False
Dim HlLt As Long
HlLt = Options.DefaultHighlightColorIndex
Options.DefaultHighlightColorIndex = wdYellow
With ActiveDocument.Range.Find
  .ClearFormatting
  .Replacement.ClearFormatting
  .Text = "<[!^09-^13 ][!^09-^13 ]@ing>"
  .Replacement.Highlight = True
  .Replacement.Text = "^&"
  .Forward = True
  .Wrap = wdFindStop
  .Format = True
  .MatchWildcards = True
  .Execute Replace:=wdReplaceAll
End With
Options.DefaultHighlightColorIndex = HlLt
Application.ScreenUpdating = True
End Sub
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Forum statistics

Threads
1,217,389
Messages
6,136,322
Members
450,003
Latest member
AnnetteP

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top