Excel VBA条件格式

发布于 2024-11-19 13:06:17 字数 400 浏览 1 评论 0原文

我想在 Excel 中使用预定义的条件格式生成某些 vels。如果输入数字 1,则应显示 3 个未圈出的符号中的绿色图标。到目前为止,这是我的代码:

Sub AddIconCondFormat(cell1 As range, cell2 As range)

    range(cell1, cell2).Select
    With Selection
        .FormatConditions.Delete
       '.FormatConditions.Add Type:=xlCellValue, Operator:XlEqual, Formula1:
    End With

End Sub

我不知道 .FormatConditions 的所有必要参数。有人知道他们是否列在某个地方吗?

I want to generate certain vells in Excel with predefined conditional formatting. If number 1 is entered the green icon from 3 symbols uncircled should be shown. Here is my code so far:

Sub AddIconCondFormat(cell1 As range, cell2 As range)

    range(cell1, cell2).Select
    With Selection
        .FormatConditions.Delete
       '.FormatConditions.Add Type:=xlCellValue, Operator:XlEqual, Formula1:
    End With

End Sub

I don't know all the necessary parameters for .FormatConditions. Does someone know if they are listed somewhere?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

瞎闹 2024-11-26 13:06:17

使用宏录制后,我得到了有效的代码:

Sub AddIconCondFormat(cell1 As range, cell2 As range)

range(cell1, cell2).Select
With Selection
    .FormatConditions.Delete
    .FormatConditions.AddIconSetCondition
    .FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1)
        .ReverseOrder = False
        .ShowIconOnly = False
        .IconSet = ActiveWorkbook.IconSets(xl3Symbols2)
    End With
    With Selection.FormatConditions(1).IconCriteria(2)
        .Type = xlConditionValuePercent
        .Value = 33
        .Operator = 7
    End With
    With Selection.FormatConditions(1).IconCriteria(3)
        .Type = xlConditionValuePercent
        .Value = 67
        .Operator = 7
    End With
End With

End Sub

After using macro recording I got this code which works:

Sub AddIconCondFormat(cell1 As range, cell2 As range)

range(cell1, cell2).Select
With Selection
    .FormatConditions.Delete
    .FormatConditions.AddIconSetCondition
    .FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1)
        .ReverseOrder = False
        .ShowIconOnly = False
        .IconSet = ActiveWorkbook.IconSets(xl3Symbols2)
    End With
    With Selection.FormatConditions(1).IconCriteria(2)
        .Type = xlConditionValuePercent
        .Value = 33
        .Operator = 7
    End With
    With Selection.FormatConditions(1).IconCriteria(3)
        .Type = xlConditionValuePercent
        .Value = 67
        .Operator = 7
    End With
End With

End Sub
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文