H
hotherps
I have the following code that changes the font color of the cell red if
the value is lower in the previous cell, and if the value increases it
should be green. What I want to do is make it conditional based on a
text value in column C that preceeds each row.
for example if the value in cell C42 = "Cost" then I want the font to
turn red if the amount goes up.
But if the value in column C42 starts with "Production" I want to
reverse the condition, and use the green font.
I just can't get it to work, thanks
For Each cell_in_loop In Range("D42
142")
If cell_in_loop.Value > cell_in_loop.Offset(0, -1) Then
With cell_in_loop.Offset(0, 0).Font
ColorIndex = 10
'.Pattern = xlSolid
End With
End If
If cell_in_loop.Value < cell_in_loop.Offset(0, -1) Then
With cell_in_loop.Offset(0, 0).Font
ColorIndex = 3
'.Bold = True
End With
End If
Next
Jim
the value is lower in the previous cell, and if the value increases it
should be green. What I want to do is make it conditional based on a
text value in column C that preceeds each row.
for example if the value in cell C42 = "Cost" then I want the font to
turn red if the amount goes up.
But if the value in column C42 starts with "Production" I want to
reverse the condition, and use the green font.
I just can't get it to work, thanks
For Each cell_in_loop In Range("D42

If cell_in_loop.Value > cell_in_loop.Offset(0, -1) Then
With cell_in_loop.Offset(0, 0).Font
ColorIndex = 10
'.Pattern = xlSolid
End With
End If
If cell_in_loop.Value < cell_in_loop.Offset(0, -1) Then
With cell_in_loop.Offset(0, 0).Font
ColorIndex = 3
'.Bold = True
End With
End If
Next
Jim