View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Change Font Colour and Background If Q


'-----------------------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
'-----------------------------------------------------------------
Const WS_RANGE As String = "H1:H10" '<==== 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 "london":
.Font.ColorIndex = 2
.Interior.ColorIndex = 3 'red
etc.
End Select
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub


'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.





--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

wrote in message
ups.com...
I wish to change the Font & Background colour if a cell = a certain
value.

I can't use Conditional Formatting as I have 28 variables that the cell
value could be. I have seen an add-in on this Newgroup, but I'm trying
to design a workbook for 5 users and I dont wish to install this on
each Laptop.

My Workbook will have a Data Validation Drop down list that the user
will select a certain location from, if the location Selected =
"London" I wish for the Background to change to Red and Font to White
etc etc

How would I do this through VB

Thanks for any help