首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何为条件自定义图标

如何为条件自定义图标
EN

Stack Overflow用户
提问于 2019-07-24 12:18:11
回答 2查看 687关注 0票数 2

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

条件如下:

  1. 值< 0.85
  2. 值< 0.95
  3. 值< 1.06
  4. 数值< 1.15
  5. 值>=1.15

我想用这样的方式来使用3个交通灯:

  1. 值< 0.85 ->“红绿灯”
  2. 值< 0.95 ->“橙色交通灯”
  3. 值< 1.06 ->“绿色交通灯”
  4. 值< 1.15 ->“橙色交通灯”
  5. 值>=1.15 ->“红绿灯”

我自愿使用xl5Arrows来获得这5个条件。

代码语言:javascript
运行
复制
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

这段代码可以工作,但是我希望Traffic lights而不是xl5Arrows

非常感谢你的帮助。如果你需要更多的细节,不要犹豫评论。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-07-24 16:13:05

作为马克·S.枚举中没有默认的xl5trafficlights

但是,您目前正在设置您的.Type.Value.Operator,只需确保同时设置.Icon。这将将IconSetCriteria设置为xlCustomSet

这是一个xlIcon -“圆圈”,为您建立您的5个交通灯设置如下:

代码语言:javascript
运行
复制
xlIconBlackCircleWithBorder
xlIconGrayCircle
xlIconGreenCircle
xlIconRedCircleWithBorder
xlIconPinkCircle
xlIconYellowCircle
xlIconGreenCheckSymbol
xlIconRedCrossSymbol
xlIconYellowExclamationSymbol
xlIconWhiteCircleAllWhiteQuarters

例如:

代码语言:javascript
运行
复制
    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
票数 2
EN

Stack Overflow用户

发布于 2019-07-24 13:01:58

然而,对于图标设置,我不相信有一个格式的5个红绿灯,只有xl3TrafficLights1,xl4TrafficLights或xl3TrafficLights2。你可以在这里读到

此外,基于您所说的设置条件的组件应该是.Operator = xlLess.Operator =xlGreaterEqual

  1. 值< 0.85 (xlLess)
  2. 值< 0.95 (xlLess)
  3. 值< 1.06 (xlLess)
  4. 值< 1.15 (xlLess)
  5. 值>=1.15 (xlGreaterEqual)
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57182771

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档