Forum Discussion

LesKing's avatar
LesKing
Brass Contributor
Apr 06, 2023
Solved

Conditional Formatting

The Macro below works perfectly when column “L” is filled with numbers BUT it will actually be filled with dates, and I cannot work out how to make it work when column L has dates in it. Can anyone h...
  • HansVogelaar's avatar
    Apr 06, 2023

    LesKing 

    Try this:

    Sub CriticalDates()
        Dim rng As Range
        Dim isc As IconSetCondition
        Set rng = Range("L1", Range("L1").End(xlDown))
        rng.FormatConditions.Delete
        Set isc = rng.FormatConditions.AddIconSetCondition
        With isc
            .ReverseOrder = False
            .ShowIconOnly = False
            .IconSet = ActiveWorkbook.IconSets(xl3TrafficLights1)
            With .IconCriteria(2)
                .Type = xlConditionValueFormula
                .Value = "=TODAY()+30"
                .Operator = xlGreaterEqual
            End With
            With .IconCriteria(3)
                .Type = xlConditionValueFormula
                .Value = "=TODAY()+60"
                .Operator = xlGreaterEqual
            End With
        End With
    End Sub

Resources