G
Gene-Salkovsky
I have a table that is 8 columns across and multiple rows. The 2nd row is my
conditional. If it is filled with "X" or "x" it will fomat the last 5
columns of that row in a dark gray background. If it is Blank, it will not
do anything. This needs to start on the first row and run until the end of
the document.
I have been able to create the macro that turns the last 5 columns gray
(With my cursor in the 2nd cell) . This will work for doing this one row at
a time, but I would prefer to do this all at once by clicking in row 1 / cell
2. I found something else with FOR/NEXT, but not able to get it to work.
This, in theory, is what I am looking for below.
Thank you.
Gene
conditional. If it is filled with "X" or "x" it will fomat the last 5
columns of that row in a dark gray background. If it is Blank, it will not
do anything. This needs to start on the first row and run until the end of
the document.
I have been able to create the macro that turns the last 5 columns gray
(With my cursor in the 2nd cell) . This will work for doing this one row at
a time, but I would prefer to do this all at once by clicking in row 1 / cell
2. I found something else with FOR/NEXT, but not able to get it to work.
This, in theory, is what I am looking for below.
Code:
Sub Macro3()
Dim TargetText As String
Dim oRow As Row
If Selection.Information(wdWithInTable) = False Then Exit Sub
TargetText = Chr(88) Or Chr(120)
For Each oRow In Selection.Tables(1).Rows
If oRow.Cells(2).Range.Text = TargetText & vbCr & Chr(7) Then
Selection.MoveRight Unit:=wdCharacter, Count:=8, Extend:=wdExtend
Selection.Shading.Texture = wdTextureNone
Selection.Shading.ForegroundPatternColor = wdColorAutomatic
Selection.Shading.BackgroundPatternColor = wdColorGray15
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.MoveRight Unit:=wdCharacter, Count:=3, Extend:=wdExtend
Selection.Shading.Texture = wdTextureNone
Selection.Shading.ForegroundPatternColor = wdColorAutomatic
Selection.Shading.BackgroundPatternColor = wdColorAutomatic
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Next oRow
End Sub
Gene