Hi, I am trying to loop through all cells in the range J10:J25. When a cell is smaller than the value in cell "D12", I want it to change color to red.
This is probably simple, but I am unsure how I can target each cell to check for the if function. ActiveCell does not seem to work.
I could not manage to find the answear on google, so I am very thankful for your help!
Here is the code I have come up with so far:
This is probably simple, but I am unsure how I can target each cell to check for the if function. ActiveCell does not seem to work.
I could not manage to find the answear on google, so I am very thankful for your help!
Here is the code I have come up with so far:
Code:
Sheets("Data").Select
Range("D12").Select
Dim rng As Range, cell As Range
Set rng = Range("J10:J25")
For Each cell In rng
If ActiveCell < Range("D12") Then
ActiveCell.Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End If
Next cell
End Sub