View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
sharakbh sharakbh is offline
external usenet poster
 
Posts: 3
Default Conditional Formatting - more than 4 cell colors

I'm getting there . . . I opened up a brand new spreadsheet to try this
again. So I posted in the following code on to the VB page and saved it.
When I went to the worksheet to Cells C1:C45 and manually typed in Carol,
Shara, etc, the cell changed to a color. YEAH! . . . BUT . . . in my
example, for the cells that already have data in them, what is the
workaround/coding to make those change to a color as well (w/o cutting and
pasting my data in order for the cells to change color)? Again, thanks for
your help JP!

Private Sub Worksheet_Change(ByVal Target As Range)
Dim WatchRange As Range
Dim CellVal As String
If Target.Cells.Count 1 Then Exit Sub
If Target = "" Then Exit Sub
CellVal = Target
Set WatchRange = Range("C1:C45")

If Not Intersect(Target, WatchRange) Is Nothing Then
Select Case CellVal
Case "Carol"
Target.Interior.ColorIndex = 5
Case "Steve"
Target.Interior.ColorIndex = 10
Case "Lulu"
Target.Interior.ColorIndex = 6
Case "Shara"
Target.Interior.ColorIndex = 46
Case "Lilian"
Target.Interior.ColorIndex = 45
End Select
End If
End Sub
--
sharakbh


"JP" wrote:

You would simply change the range in WatchRange to cover the cells
where you are placing the names. For example if you were typing the
names in cells A3:I3, change it to

Set WatchRange = Range("A3:I3")

Now type a name in one of those cells. If it still doesn't change
color, can you post the EXACT code you are using?

HTH,
JP


On Feb 29, 2:26 pm, sharakbh
wrote:
Sorry, I meant columns! :-) So, it still doesn't work for me. This is my
first time going to the VB tab to enter code. As I mentioned, I'm not a
total power user (coder), just an "avg Joe" with intermediate skill level.
Is there something I need (add-in) in order to make this work? Not sure why
it won't work, when it seems to work for previous posters. Thx for your
help! :-)
--
sharakbh