Forum Discussion
PCThomson
Jan 10, 2024Copper Contributor
Error Adding IconSets using VBA
For some reason I am unable to overcome this issue. I have a Range(B3:L12) that contains numbers between 1 and 9 inclusive. I would like to add conditional formatting to the Range(C3:L12) using 3 Arr...
HansVogelaar
Jan 10, 2024MVP
You have to specify the criteria in reverse order, and only #3 and #2. #1 follows automatically from those.
Sub UpdateIconSets()
Dim row As Integer, col As Integer
For row = 3 To 12
For col = 3 To 12
With Cells(row, col)
.FormatConditions.Delete
With .FormatConditions.AddIconSetCondition
.IconSet = ActiveWorkbook.IconSets(xl3Arrows)
.ReverseOrder = False
.ShowIconOnly = False
With .IconCriteria(2)
.Type = xlConditionValueNumber
.Operator = xlGreaterEqual
.Value = Cells(row, col).Offset(0, -1)
End With
With .IconCriteria(3)
.Type = xlConditionValueNumber
.Operator = xlGreater
.Value = Cells(row, col).Offset(0, -1)
End With
End With
End With
Next col
Next row
End SubPCThomson
Jan 11, 2024Copper Contributor
HansVogelaar Excellent thank you so much.