Change Font Colour and Background If Q
'-----------------------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
'-----------------------------------------------------------------
Const WS_RANGE As String = "D7:J30" '<==== change to suit
On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
Select Case LCase(.Value)
Case ""
.Font.ColorIndex = xlColorIndexAutomatic
.Interior.ColorIndex = xlcolroindexnone
Case "london":
.Font.ColorIndex = 2
.Interior.ColorIndex = 3 'red
Case "birmingham":
.Font.ColorIndex = 2
.Interior.ColorIndex = 4 'red
End Select
End With
End If
ws_exit:
Application.EnableEvents = True
End Sub
--
HTH
Bob Phillips
(replace somewhere in email address with gmail if mailing direct)
wrote in message
ups.com...
How would you include code that if the cell is blank the colour of the
cell would revert to "default" i.e. white
Problem at the moment is that if a location is selected the cell is
changed to the required colour but if the cell is changed to "blank"
the original colour remains
Also where can I obtain a list of colour numbers i.e. red=3; green=4
etc
Thanks
|