Excel 如何自定义条件的图标

Excel 如何自定义条件的图标,excel,vba,excel-formula,Excel,Vba,Excel Formula,我想自定义图标标准。我需要5个条件。我使用了IconSetCondition 条件是: 值0.85 5。其他值与条件一样,第一个条件是其他值,我不知道ReverseOrder是语法xlGreatEqual还是xlGreaterEqual?“我想做些调整谢谢,”亚瑟说。我会保持原样。谢谢你的回答,我明天会试试。 With .IconCriteria(1) .Icon = xlIconWhiteCircleAllWhiteQuarters End With W

我想自定义图标标准。我需要5个条件。我使用了IconSetCondition

条件是:

  • 值<0.85
  • 值<0.95
  • 值<1.06
  • 值<1.15
  • 值>=1.15
  • 我想这样使用3个交通灯:

  • 值<0.85-->“红色交通灯”
  • 值<0.95-->“橙色交通灯”
  • 值<1.06-->“绿色交通灯”
  • 值<1.15-->“橙色交通灯”
  • 值>=1.15-->“红色交通灯”
  • 我使用XL5箭头来获得5个条件

    Set r = Range(Cells(3, 6), Cells(nbtopics + 2, 6))
    With r
        With .FormatConditions
            .Delete
            .AddIconSetCondition
        End With
        With .FormatConditions(1)
            .SetFirstPriority
            .ReverseOrder = False
            .ShowIconOnly = False
            .IconSet = ActiveWorkbook.IconSets(xl5Arrows)
            With .IconCriteria(2)
                .Type = xlConditionValueNumber
                .Value = 0.85
                .Operator = xlGreater
            End With
            With .IconCriteria(3)
                .Type = xlConditionValueNumber
                .Value = 0.95
                .Operator = xlGreater
            End With
            With .IconCriteria(4)
                .Type = xlConditionValueNumber
                .Value = 1.05
                .Operator = xlGreater
            End With
            With .IconCriteria(5)
                .Type = xlConditionValueNumber
                .Value = 1.15
                .Operator = xlGreater
            End With
        End With
    End With
    
    此代码有效,但是我希望使用
    交通灯
    而不是
    xl5箭头


    非常感谢你的帮助。如果您需要更多详细信息,请随时发表评论。

    但是对于IConset,我认为没有一种格式可用于5个红绿灯,只有XL3个红绿灯1、XL4个红绿灯或XL3个红绿灯2

    此外,根据您所说的内容设置标准的组件应该是
    .Operator=xlLess
    .Operator=xlGreaterEqual

  • 值<0.85(xlLess)
  • 值<0.95(xlLess)
  • 值<1.06(xlLess)
  • 值<1.15(xlLess)
  • 值>=1.15(xlgreater相等)
  • 如前所述,系统中没有默认的
    xl5trafficlights

    但是,您当前正在设置IconCriteria的
    .Type
    .Value
    .Operator
    ——请确保同时设置
    .Icon
    。这将把
    IconSetCriteria
    设置为
    xlCustomSet

    这是一个“圆形”交通灯组,供您构建5个交通灯组,如下所示:

    xlIconBlackCircleWithBorder
    xlIconGrayCircle
    xlIconGreenCircle
    xlIconRedCircleWithBorder
    xlIconPinkCircle
    xlIconYellowCircle
    xlIconGreenCheckSymbol
    xlIconRedCrossSymbol
    xlIconYellowExclamationSymbol
    xlIconWhiteCircleAllWhiteQuarters
    
    e、 g


    嗨,亚瑟,我要做的就是使用宏记录器,做我需要做的,然后使它适合我的需要。我想你需要改变这一点:
    .IconSet=ActiveWorkbook.IconSet(xl5Arrows)
    一些
    xl5TrafficLights
    或者其他什么,你可以通过宏记录自己找到它。不幸的是没有。确实,只要选中,你只能有4个(
    xl4TrafficLights
    )谢谢你的回答。不幸的是,vba无法识别
    xl5交通灯
    。这就是为什么我使用
    xl5箭头
    来设置5个条件。使用
    xl3交通灯
    时,您必须使用
    xlGreatEqual
    xlGreater
    。所以是的,我同意它应该是1。值>1.15 2。值>1.06 3。值>0.95 4。值>0.85 5。其他值与条件一样,第一个条件是其他值,我不知道
    ReverseOrder
    是语法
    xlGreatEqual
    还是
    xlGreaterEqual
    ?“我想做些调整谢谢,”亚瑟说。我会保持原样。谢谢你的回答,我明天会试试。
        With .IconCriteria(1)
            .Icon = xlIconWhiteCircleAllWhiteQuarters
        End With
        With .IconCriteria(2)
            .Icon = xlIconGreenCircle
            .Type = xlConditionValueNumber
            .Value = 0.85
            .Operator = xlGreater
        End With
        With .IconCriteria(3)
            .Icon = xlIconYellowCircle
            .Type = xlConditionValueNumber
            .Value = 0.95
            .Operator = xlGreater
        End With
        With .IconCriteria(4)
            .Icon = xlIconRedCircleWithBorder
            .Type = xlConditionValueNumber
            .Value = 1.05
            .Operator = xlGreater
        End With
        With .IconCriteria(5)
            .Icon = xlIconBlackCircleWithBorder
            .Type = xlConditionValueNumber
            .Value = 1.15
            .Operator = xlGreater
        End With