I have a column of numbers (in percentages) which is a part of a pivot table. I need to color code this column as follows:
- Percentages above 95% "Good"
- Percentages >= 90% and lower than 95% "Neutral"
- Percentages < 90% "Bad"
I would like to use Excel Styles for colors.
I have written below code:
Sub Percentcolorcode()
Dim Score As Integer
Score = ActiveCell.Value
Select Case Score
Case Is >= 0.95
ActiveCell.Style = "Good"
Case Is >=0.9 and <0.95
ActiveCell.Style = "Neutral"
Case Is < 0.9
ActiveCell.Style = "Bad"
End Select
End Sub
It gives me an error for the line Case Is >=0.9 and <0.95. When I remove that line, I would still expect that it runs for the two other conditions, but it only color codes one cell from the selected column and that is with the wrong color.
Could someone please help with this code.
Thank you,
- Percentages above 95% "Good"
- Percentages >= 90% and lower than 95% "Neutral"
- Percentages < 90% "Bad"
I would like to use Excel Styles for colors.
I have written below code:
Sub Percentcolorcode()
Dim Score As Integer
Score = ActiveCell.Value
Select Case Score
Case Is >= 0.95
ActiveCell.Style = "Good"
Case Is >=0.9 and <0.95
ActiveCell.Style = "Neutral"
Case Is < 0.9
ActiveCell.Style = "Bad"
End Select
End Sub
It gives me an error for the line Case Is >=0.9 and <0.95. When I remove that line, I would still expect that it runs for the two other conditions, but it only color codes one cell from the selected column and that is with the wrong color.
Could someone please help with this code.
Thank you,