View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
ryguy7272 ryguy7272 is offline
external usenet poster
 
Posts: 2,836
Default Changing cell color based on a value in another cell

This should do what you want:

Sub ColorCells()
Dim rCell As Range
Dim nCount As Long
With Range("Z7:Z100")
..Interior.ColorIndex = xlColorIndexNone
For Each rCell In .Cells
If rCell = "2" Then
rCell.Offset(0, -23).Interior.ColorIndex = 6
End If
If rCell = "3" Then
rCell.Offset(0, -23).Interior.ColorIndex = 3
End If
If rCell "3" Then
rCell.Offset(0, -23).Interior.ColorIndex = 15
End If

Next rCell
End With
End Sub


Regards,
Ryan--

--
RyGuy


"ordnance1" wrote:

I need a macro which will look at each row and if the cell in column Z =2
then the cell in column C should be formatted Yellow, if it = 3 the cell will
be formatted Red and if it is greater than 3 the cell will be formatted
Grey. There are 941 rows startimng at row 7. I know this can be done as a
conditional format, but this is for use with Office 2003 and because of other
conditional formats I am using I have exceeded the three allowed conditional
formats