DrParmeJohnson
New Member
- Joined
- Feb 28, 2019
- Messages
- 44
Hello, I have been struggling to get this macro to work in totality and this part has been giving me troubles.
I currently have two loops which do similar things, but I can't get them to work.
Ths isn't the whole macro so not everything is defined here.
What I'm trying to make the first do is loop through from F2 to Lastrow and for each cell where the value is greater than .1 and less than 1 (the values are written in percentage form "0.00%") and for the values that are in that range, highlight them red.
And for the second loop, it does the same but in the range where it is less than .1 and greater than 0 and then highlight that green.
I've mostly just cannibalized most of this macro from the recorder and other things I have found online and I am not sure what actually works together and why this isn't working properly.
Any other questions on things I may have left out, please ask, I am quite sick of dealing with these loops.
Thanks.
I currently have two loops which do similar things, but I can't get them to work.
VBA Code:
Dim i As Variant
For Each i In Range("F2:F" & Lastrow).Cells
If i.Value > 0.1 & i.Value < 1 Then
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 7434751
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End If
Next i
Dim c As Variant
For Each c In Range("F2:F" & Lastrow).Cells
If c.Value < 0.1 & c.Value > 0 Then
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent6
.TintAndShade = 0.399975585192419
.PatternTintAndShade = 0
End With
End If
Next c
Ths isn't the whole macro so not everything is defined here.
What I'm trying to make the first do is loop through from F2 to Lastrow and for each cell where the value is greater than .1 and less than 1 (the values are written in percentage form "0.00%") and for the values that are in that range, highlight them red.
And for the second loop, it does the same but in the range where it is less than .1 and greater than 0 and then highlight that green.
I've mostly just cannibalized most of this macro from the recorder and other things I have found online and I am not sure what actually works together and why this isn't working properly.
Any other questions on things I may have left out, please ask, I am quite sick of dealing with these loops.
Thanks.