Cell formatting
Brian T wrote:
I am trying set the cell color for a range of cells by determining the value
of a cell in the range. For example if A4=1, I want that row 4 to be red and
if a4=0, I want the row to have no color. But my whole range turns red.
Here is the code that I have done so far. What am I not getting?
Sub FormatCells()
'Create Class 1 Variables
'Class_1 is all information
'LastInsp in the time since the last inspection.
Dim Class_1 As Range
Dim LastInsp As Range
Set Class_1 = Range("a4:s41")
Set LastInsp = Range("a4:a41")
'Set color in range.
'Colored background shows that inspection is out of date.
Class_1.Interior.ColorIndex = x1None
For Each Class_1 In Range("a4:s41")
If LastInsp = 1 Then
Class_1.Interior.ColorIndex = 3
ElseIf LastInsp = 0 Then
Class_1.Interior.ColorIndex = x1None
End If
Next
Conditional Formatting
|