Hi all,
I need to format cells based on 7 different criteria so the normal 3 criteria option is no use.
I've read the earlier threads and copied the script given into VBE and it works, but not quite as I want it.
I have 2 problems with what I've done so far :-
1. The script colours the cell background, but I can't find where to see the list of colours so that I can get the cells to change to the colour I need. Are the colours and corresponding codes listed somewhere ?
2. The cells which are changed to fairly dark background colours need to have the font colour changed to white (I want 3 of my 7 options to have white text). What additions do I have to make to the script to get this to happen at the same time ?
The script I have in VBE at the moment is :-
Private Sub Worksheet_Change(ByVal Target As Range)
Dim oCell As Range
For Each oCell In Target
Select Case oCell.Value
Case Is = "P"
oCell.Interior.ColorIndex = 5
Case Is = "H"
oCell.Interior.ColorIndex = 3
Case Is = "F"
oCell.Interior.ColorIndex = 28
Case Is = "S"
oCell.Interior.ColorIndex = 36
Case Is = "T"
oCell.Interior.ColorIndex = 15
Case Is = "C"
oCell.Interior.ColorIndex = 48
Case Is = "O"
oCell.Interior.ColorIndex = 44
Case Else
oCell.Interior.ColorIndex = xlNone
End Select
Next oCell
End Sub
Thanks for looking. Hope you can help,
Regards,
Jock
I need to format cells based on 7 different criteria so the normal 3 criteria option is no use.
I've read the earlier threads and copied the script given into VBE and it works, but not quite as I want it.
I have 2 problems with what I've done so far :-
1. The script colours the cell background, but I can't find where to see the list of colours so that I can get the cells to change to the colour I need. Are the colours and corresponding codes listed somewhere ?
2. The cells which are changed to fairly dark background colours need to have the font colour changed to white (I want 3 of my 7 options to have white text). What additions do I have to make to the script to get this to happen at the same time ?
The script I have in VBE at the moment is :-
Private Sub Worksheet_Change(ByVal Target As Range)
Dim oCell As Range
For Each oCell In Target
Select Case oCell.Value
Case Is = "P"
oCell.Interior.ColorIndex = 5
Case Is = "H"
oCell.Interior.ColorIndex = 3
Case Is = "F"
oCell.Interior.ColorIndex = 28
Case Is = "S"
oCell.Interior.ColorIndex = 36
Case Is = "T"
oCell.Interior.ColorIndex = 15
Case Is = "C"
oCell.Interior.ColorIndex = 48
Case Is = "O"
oCell.Interior.ColorIndex = 44
Case Else
oCell.Interior.ColorIndex = xlNone
End Select
Next oCell
End Sub
Thanks for looking. Hope you can help,
Regards,
Jock