x_swinson_x
New Member
- Joined
- Feb 10, 2016
- Messages
- 18
This is the code that I have for conditional formatting. What I want to happen is as follows
Cells that contain numbers between 0 and 1 to be red
Cells that contain numbers greater than 1 and less than 100 to be yellow
Cells that contain numbers equal to 100 to be green
Here's the current code I'm working with:
Currently the code isn't changing any of the cell backgrounds. Any advice?
Excel 2016, Windows 7
Cells that contain numbers between 0 and 1 to be red
Cells that contain numbers greater than 1 and less than 100 to be yellow
Cells that contain numbers equal to 100 to be green
Here's the current code I'm working with:
Code:
Dim d As DoubleDim r As Range
Set r = ActiveSheet.Range("B15:AF38")
For Each Cell In r
If Cell.Text <> "" And IsNumeric(Cell.Value) = True Then
If Cell.Value > 0 And Cell.Value < 1 Then
Cell.Interior.Color = RGB(255, 0, 0)
If Cell.Value > 100 Then
Cell.Interior.Color = RGB(0, 255, 0)
If Cell.Value > 1 And Cell.Value < 100 Then
Cell.Interior.Color = RGB(255, 255, 0)
End If
End If
End If
End If
Next
Currently the code isn't changing any of the cell backgrounds. Any advice?
Excel 2016, Windows 7