Hi Preacherman
You can achieve what you want without a macro, if you have Word 2002 or
2003. To do that, select the whole table. Use Edit > Find. In the Find What
box, type your "XX" text. Tick the "Highlight all items found in" box (which
should say "Current selection"). Click Find All, and then Close. You'll see
that Word has selected all cells containing "XX". Now, use Format > Borders
and Shading to shade the cells.
However, if you need a macro to do this, you could use the following code.
You'll need to change XX to the text you need to find.
Sub FindTextInATableAndShadeCell()
' Posted to microsoft.public.word.tables newsgroup
' Shauna Kelly 15/8/2004.
Dim oCell As Cell
Dim sTextToFind As String
If Selection.Information(wdWithInTable) = False Then
MsgBox "Cursor is not currently in a table"
Else
sTextToFind = "XX"
'Find cells in the current table that contain
'sTextToFind, and shade the cell
Selection.Tables(1).Select
With Selection.Find
.ClearFormatting
.Text = sTextToFind
.Wrap = wdFindStop
Do While .Execute
Selection.Cells(1).Shading.BackgroundPatternColorIndex =
wdGray25
Loop
End With
End If
End Sub
If you're not sure what to do with the macro, see
http://www.gmayor.com/installing_macro.htm and
http://www.mvps.org/word/FAQs/MacrosVBA/CreateAMacro.htm
Hope this helps.
Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
> In Microsoft Word table I want to find a letter combination XX, shade that
> cell, move to the next XX, shade it, etc. to the end of the table. It
> works
> beautifully in Word Perfect, and there should be a way to do it in Word.
Preacherman - 15 Aug 2004 03:27 GMT
Shauna Kelly,
Thanks for the idea. I haven't tried it yet, but it sure sounds like it
will work.
Preacherman
> Hi Preacherman
>
[quoted text clipped - 51 lines]
> > works
> > beautifully in Word Perfect, and there should be a way to do it in Word.
Peacherman,
My code is likely rough, because I am just learning. Something like this
might work
Sub ShadeDesigCells()
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
.Text = "XX"
.Forward = True
.Wrap = wdFindContinue
Do While Selection.Find.Execute = True
Selection.EndKey
With Selection.Cells.Shading
.Texture = wdTextureNone
.ForegroundPatternColor = wdColorAutomatic
.BackgroundPatternColor = wdColorGray30
End With
Loop
End With
End Sub

Signature
Greg Maxey
A peer in "peer to peer" support
Rockledge, FL
To e-mail, edit out the "w...spam" in gmaxey@whamspammvps.org
> In Microsoft Word table I want to find a letter combination XX, shade
> that cell, move to the next XX, shade it, etc. to the end of the
> table. It works beautifully in Word Perfect, and there should be a
> way to do it in Word.
Greg Maxey - 15 Aug 2004 02:06 GMT
PM,
As I suspected, Shauna's appears far better.
Here is a slight adaptation with a input box for identifying the the find
text.
Sub FindTextInATableAndShadeCell()
Dim oCell As Cell
Dim fText As String
If Selection.Information(wdWithInTable) = False Then
MsgBox "Cursor is not currently in a table"
Else
fText = InputBox$("Enter text to find.", "Find")
Selection.Tables(1).Select
With Selection.Find
.ClearFormatting
.Text = fText
.Wrap = wdFindContinue
Do While .Execute
Selection.Cells(1).Shading.BackgroundPatternColor = wdColorGray10
Loop
End With
End If
End Sub

Signature
Greg Maxey
A peer in "peer to peer" support
Rockledge, FL
To e-mail, edit out the "w...spam" in gmaxey@whamspammvps.org
> Peacherman,
>
[quoted text clipped - 23 lines]
>> table. It works beautifully in Word Perfect, and there should be a
>> way to do it in Word.
Preacherman - 15 Aug 2004 03:29 GMT
Greg,
I think I will try Shauna's way first, but will come back for yours if I
have trouble with it. By the way, are you related to Mark or Tibbs Maxey?
Preacherman
> Peacherman,
>
[quoted text clipped - 23 lines]
> > table. It works beautifully in Word Perfect, and there should be a
> > way to do it in Word.
Greg Maxey - 15 Aug 2004 04:39 GMT
Shauna's
Suggestion to use the FIND dialog works great and her macro works well also.
I don't know Mark or Tibbs. Unlike a Smith or Jones, there isn't that awful
many of us and I suppose going back far enough there could be relation some
way:-)

Signature
Greg Maxey
A peer in "peer to peer" support
Rockledge, FL
To e-mail, edit out the "w...spam" in gmaxey@whamspammvps.org
> Greg,
> I think I will try Shauna's way first, but will come back for yours
[quoted text clipped - 34 lines]
>>> the table. It works beautifully in Word Perfect, and there should
>>> be a way to do it in Word.