S
Singing Villan
Have a table in Word (eg 20x20), and I wish to look at cells (6,1)-(6,6) &
apply conditional formatting. Code works for all cells, but I can't work out
how to address specific cells.
Dim RAG1, RAG2 As String
Dim iRow, jCol As Integer
For Each t In ActiveDocument.Tables
For Each Cell In t.Range.Cells
For iRow = 6 To 6
For jCol = 1 To 6
RAG1 = Cells(iRow, jCol).Selection.Text ' Compile error *******
RAG2 = Left(RAG1, 1)
Select Case RAG2
Case "A"
Cell.Shading.BackgroundPatternColor = wdColorGold
Case "R"
Cell.Shading.BackgroundPatternColor = wdColorRed
Case "G"
Cell.Shading.BackgroundPatternColor = wdColorBrightGreen
Case "C"
Cell.Shading.BackgroundPatternColor = wdColorBlue
Case "H"
Cell.Shading.BackgroundPatternColor = wdColorYellow
Case Else
Cell.Shading.BackgroundPatternColor = wdColorLightYellow
End Select
Next
Next
Next
Next
apply conditional formatting. Code works for all cells, but I can't work out
how to address specific cells.
Dim RAG1, RAG2 As String
Dim iRow, jCol As Integer
For Each t In ActiveDocument.Tables
For Each Cell In t.Range.Cells
For iRow = 6 To 6
For jCol = 1 To 6
RAG1 = Cells(iRow, jCol).Selection.Text ' Compile error *******
RAG2 = Left(RAG1, 1)
Select Case RAG2
Case "A"
Cell.Shading.BackgroundPatternColor = wdColorGold
Case "R"
Cell.Shading.BackgroundPatternColor = wdColorRed
Case "G"
Cell.Shading.BackgroundPatternColor = wdColorBrightGreen
Case "C"
Cell.Shading.BackgroundPatternColor = wdColorBlue
Case "H"
Cell.Shading.BackgroundPatternColor = wdColorYellow
Case Else
Cell.Shading.BackgroundPatternColor = wdColorLightYellow
End Select
Next
Next
Next
Next