Hilight a row in a table

S

simmo

Hi all,

I have been using this macro to highlight names in a table in word.
Is it possible to modify it, so it will highlight the row that the
name is on in the table with a cell fill colour of say blue.


Thanks


Justin


Sub Namesred()
'
' Macro2 Macro
' Macro recorded 28/04/2008 by Simmo
'
Dim rDcm As Range
Dim x As Long
Dim arrU() As String
Dim arrB() As String
arrU = Split("Y Age%M Arnold%N Barras%K Billing %J Wood", "%")


arrB = Split("RECORD", ",") ' bold
For x = 0 To UBound(arrU)
Set rDcm = ActiveDocument.Range
With rDcm.Find
..Text = "<" & arrU(x) & ">"
..MatchWildcards = True
..Replacement.Font.Color = wdColorRed
..Replacement.Text = "^&"
..Execute Replace:=wdReplaceAll
End With
Next
For x = 0 To UBound(arrB)
Set rDcm = ActiveDocument.Range
With rDcm.Find
..Text = "<" & arrB(x) & ">"
..MatchWildcards = True
..Replacement.Font.Bold = True
..Replacement.Text = "^&"
..Execute Replace:=wdReplaceAll
End With
Next
ActiveDocument.Range(0, 0).Select
End Sub
 
H

Helmut Weber

Hi Simmo,

can't tell about all of your code.
It's as bit too complicated for me.
But for applying a shading to all of the cells in a row,
where your search expression is to be found,
something along these lines:

Sub Testxas()
Dim rDcm As Range
Dim rCll As Cell
Set rDcm = ActiveDocument.Range
With rDcm.Find
.Text = "Test"
While .Execute And rDcm.Information(wdWithInTable)
For Each rCll In rDcm.Rows(1).Cells
With rCll.Shading
.Texture = wdTextureNone
.ForegroundPatternColor = wdColorAutomatic
.BackgroundPatternColor = wdColorblue
End With
Next
Wend
End With
End Sub

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 
S

simmo

Hi Simmo,

can't tell about all of your code.
It's as bit too complicated for me.
But for applying a shading to all of the cells in a row,
where your search expression is to be found,
something along these lines:

Sub Testxas()
Dim rDcm As Range
Dim rCll As Cell
Set rDcm = ActiveDocument.Range
With rDcm.Find
   .Text = "Test"
   While .Execute And rDcm.Information(wdWithInTable)
      For Each rCll In rDcm.Rows(1).Cells
         With rCll.Shading
            .Texture = wdTextureNone
            .ForegroundPatternColor = wdColorAutomatic
            .BackgroundPatternColor = wdColorblue
         End With
      Next
   Wend
End With
End Sub

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP

Hi Helmut

Thanks for taking the time to help.
I’m not experienced enough to use the code within this code.

Thanks once again
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top