View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Ken Johnson
 
Posts: n/a
Default Yet another cell color question.

Hi, I don't know of a way to get conditional formatting to do what you
want, but I think if you paste the following event procedure into the
code module of the sheet you have set up then the same effect will be
achieved. With this event procedure if you change any of the cells
above row 25, not in column A and not in any column to the right of
your set up columns, then if the new value in the changed cell is equal
to the value in column A in the same row the shading of the cell with
the SUM formula changes from light turquoise (colorindex value = 34) to
pale yellow (colorindex value = 36).

To get the code in place...

1.Copy the code
2.Right click the sheet tab. A contextual popup menu should appear.
3.Select View code from that popup.
4.Paste the code
5.Press Alt + F11 to return to the worksheet.

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo Problem
Dim NumCols As Integer
NumCols = Cells(25, Range("1:1").Columns.Count).End(xlToLeft).Column
If Target.Column NumCols Or Target.Row 24 Then Exit Sub
Application.EnableEvents = False
If Target.Value = Cells(Target.Row, 1).Value Then
Cells(25, Target.Column).Interior.ColorIndex = 36 'pale yellow fill
Else: Cells(25, Target.Column).Interior.ColorIndex = 34 'light
turquoise
End If
Problem: Application.EnableEvents = True
End Sub

Change the colorindex values to suit your needs.
You should be able to find all the values and their appearances in VBA
Help.

Ken Johnson