带图标集的条件格式

时间:2015-10-30 18:49:51

标签: excel vba formatting conditional

我无法弄清楚这段代码的问题:

     With .Range("K8:K" & lRow)
        Set IconCondn = .FormatConditions.AddIconSetCondition

        With IconCondn.FormatConditions(1)
            .ReverseOrder = True
            .ShowIconOnly = False
            .IconSet = ActiveWorkbook.IconSets(xl3Symbols)
        End With
        With IconCondn.FormatConditions(1).IconCriteria(2)
            .Type = xlConditionValueNumber
            .Value = loLi
            .Operator = 7
        End With
        With IconCondn.FormatConditions(1).IconCriteria(3)
            .Type = xlConditionValueNumber
            .Value = upLi
            .Operator = 7
        End With
     End With  

第三行With IconCondn.FormatConditions(1)给我一个错误。

1 个答案:

答案 0 :(得分:0)

With .Range("K8:K" & lRow)
        Set IconCondn = .FormatConditions.AddIconSetCondition

        With IconCondn.IconCriteria(1)
            .ReverseOrder = True
            .ShowIconOnly = False
            .IconSet = ActiveWorkbook.IconSets(xl3Symbols)
        End With
        With IconCondn.IconCriteria(2)
            .Type = xlConditionValueNumber
            .Value = loLi
            .Operator = 7
        End With
        With IconCondn.IconCriteria(3)
            .Type = xlConditionValueNumber
            .Value = upLi
            .Operator = 7
        End With
     End With  

我认为添加.FormatConditions(1)是个问题,这个部分是不必要的。有关详细信息,请参阅this page