![]() |
|
|
|
#1
|
||||
|
||||
|
Yes, it's possible to test for specific strings. For example: Code:
Sub Demo()
Application.ScreenUpdating = False
Dim oCell
For Each oCell In Selection.Tables(1).Range.Cells
With oCell.Range
If Split(.Text, vbCr)(0) = "Ltd." Then .HighlightColorIndex = wdYellow
If Split(.Text, vbCr)(0) = "Inc." Then .HighlightColorIndex = wdYellow
End With
Next
Application.ScreenUpdating = True
End Sub
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim Rng As Range
With Selection.Tables(1)
Set Rng = .Range
With .Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "[LI][tn][dc]."
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchWildcards = True
End With
Do While .Find.Execute
If .InRange(Rng) = False Then Exit Do
With .Cells(1).Range
If Split(.Text, vbCr)(0) = "Ltd." Then .HighlightColorIndex = wdYellow
If Split(.Text, vbCr)(0) = "Inc." Then .HighlightColorIndex = wdYellow
End With
.Collapse wdCollapseEnd
Loop
End With
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
| Tags |
| highlight cells, less than 5 characters |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Highlight only the characters ER when it occurs in SEVERE.
|
norgro | Word VBA | 3 | 02-18-2013 05:14 PM |
How to highlight the row based on cell value?
|
Learner7 | Excel | 1 | 12-11-2011 02:28 AM |
Highlight the first X number of characters
|
14spar15 | Word | 1 | 11-13-2011 11:17 PM |
| find - reading highlight - highlight all / highlight doesn't stick when saved | bobk544 | Word | 3 | 04-15-2009 03:31 PM |
| highlight cell after checkbox | flatk | Word | 0 | 01-25-2007 12:32 PM |