K
K. Georgiadis
I'm using the following code (compliments of Otto
Moehrbach)to color cells a specific color, depending on
cell contents:
Sub ChangeColor()
Dim Cell As Range
Dim RngToCheck As Range
With Sheets("Chart")
Set RngToCheck = .Range("B9:G20", .Range
(.UsedRange.Address))
End With
For Each Cell In RngToCheck
With Sheets("Chart")
Select Case .Range(Cell.Address).Value
Case "EX"
Cell.Interior.Color = vbMagenta
Case "CS"
Cell.Interior.Color = vbGreen
Case "GE"
Cell.Interior.Color = vbRed
Case "RE"
Cell.Interior.Color = vbBlue
Case Else
Cell.Interior.Color = vbWhite
End Select
End With
Next Cell
End Sub
My question is: how can I make the font color to match
the cell background, so that the code word contained in
the cell(e.g., "GE") becomes invisible?
Also how can I adjust the code so that it accepts upper,
lower, or mixed cases (e.g., GE, Ge, ge)?
Thanks a bunch
Moehrbach)to color cells a specific color, depending on
cell contents:
Sub ChangeColor()
Dim Cell As Range
Dim RngToCheck As Range
With Sheets("Chart")
Set RngToCheck = .Range("B9:G20", .Range
(.UsedRange.Address))
End With
For Each Cell In RngToCheck
With Sheets("Chart")
Select Case .Range(Cell.Address).Value
Case "EX"
Cell.Interior.Color = vbMagenta
Case "CS"
Cell.Interior.Color = vbGreen
Case "GE"
Cell.Interior.Color = vbRed
Case "RE"
Cell.Interior.Color = vbBlue
Case Else
Cell.Interior.Color = vbWhite
End Select
End With
Next Cell
End Sub
My question is: how can I make the font color to match
the cell background, so that the code word contained in
the cell(e.g., "GE") becomes invisible?
Also how can I adjust the code so that it accepts upper,
lower, or mixed cases (e.g., GE, Ge, ge)?
Thanks a bunch