Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I am trying to fill the color of a cell based on if statements, but I don't know how to reference the cell. Everything works except when I try to reference the CellValue to fill the cell and I am not sure what I am doing wrong because I am only a novice at VBA. My code looks like Sub Macro2() Dim lastyear As Double Dim target As Double Dim CellValue As Double Dim i As Integer For i = 5 To 15 CellValue = Cells(i, 37) target = Cells(i, 3) * 100 lastyear = Cells(i, 25) If CellValue = lastyear And CellValue = target Then CellValue.Interior.ColorIndex = 4 ElseIf CellValue = lastyear And CellValue < target Then CellValue.Interior.ColorIndex = 3 ElseIf CellValue < lastyear And CellValue < target Then CellValue.Interior.ColorIndex = 6 Else CellValue.Interior.ColorIndex = 3 End If Next End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Changing the fill color of a cell | Excel Discussion (Misc queries) | |||
Changing Fill color choices | Excel Discussion (Misc queries) | |||
Changing cell fill color as result of 'if' statement | Excel Programming | |||
Changing cell fill color as result of 'if' statement | Excel Programming | |||
Changing cell fill color as result of 'if' statement | Excel Programming |