I can get this to work on a single range of cells but I can’t get it to work on a second or third range of cells. My goal is to be able to change the “Goal” value in a primary cell and have the range of cells associated with that goal change colors from red, green, or black if they meet, exceed, or are below the goal.
Goal 95% then any cell that is less than 95% the font color will be red.
Goal 95% then any cell that is Greater than 95% the font color will be red.
and so on...
Here's the code I have at the moment and am currently getting a compile error of Next without For and I'm pretty much stuck at this point.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
Dim cell As Range
Dim Stroke As Range
Dim IMM As Range
Dim Measure As String
Set rng = Range("F4:K8")
Set Stroke = Range("F4:K4")
Set IMM = Range("F5:K5")
'Measure = Range("D4")
For Each cell In rng
'Stroke
If Stroke Then
Measure = Range("D4")
If cell = Measure Then
cell.Font.Color = 0 'Black
ElseIf cell > Measure Then
cell.Font.Color = 32768 'Green
ElseIf cell < Measure Then
cell.Font.Color = 128 'Red
End If
'Immunization
If IMM Then
Measure = Range("D5")
If cell = Measure Then
cell.Font.Color = 0 'Black
ElseIf cell > Measure Then
cell.Font.Color = 32768 'Green
ElseIf cell < Measure Then
cell.Font.Color = 128 'Red
End If
Next cell
End Sub
Any help is appreciated, thanks.
Bookmarks