View Single Post
  #5   Report Post  
Ken Wright
 
Posts: n/a
Default

You can change pretty much most things wrt a cell's contents or appearance.
Typical way of doing this if you have multiple scenarios would be to use a
Select Case structure as decsribed by Julie. If you want to add other
elements to what you want changed then consider something like this. Note
that you can specifically set the area (and in fact need to with this
example), eg

Private Sub Worksheet_Change(ByVal Target As Range)
Dim oCell As Range
Dim rng As Range
Set rng = Range("A10:D20")
Application.EnableEvents = False
On Error GoTo CleanUp
If Not Intersect(Target, rng) Is Nothing Then
For Each oCell In rng
With oCell
Select Case .Value
Case Is = "Tom"
.Interior.ColorIndex = 1
.Font.ColorIndex = 3
Case Is = "Dick"
.Interior.ColorIndex = 4
.Font.ColorIndex = 6
Case Is = "Harry"
.Interior.ColorIndex = 5
.Font.ColorIndex = 9
Case Is = "Fred"
.Interior.ColorIndex = 7
.Font.ColorIndex = 10
Case Else
.Interior.ColorIndex = xlNone
End Select
End With
Next oCell
End If
CleanUp:
Application.EnableEvents = True
End Sub

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 97/00/02/03

----------------------------------------------------------------------------
It's easier to beg forgiveness than ask permission :-)
----------------------------------------------------------------------------

<snip