【问题标题】:conditional formatting in Excel to highlight important datesExcel 中的条件格式以突出显示重要日期
【发布时间】:2012-03-15 15:57:17
【问题描述】:

我有一个包含数百个日期的 Excel 工作表。无论如何,是否有条件格式化这些单元格以突出显示快速接近的日期为红色,以及遥远的未来日期为绿色?

【问题讨论】:

    标签: excel vba


    【解决方案1】:

    什么版本的 Excel?在 Excel 2010(我猜是 2007 年)中,您可以使用从红色开始的分级色标,然后在您的日期范围内更改为绿色。事实上,红-黄-绿刻度是“条件格式”功能区项下的选项之一。

    要使用 VBA 设置条件格式,请使用如下宏:

    Selection.FormatConditions(1).ColorScaleCriteria(1).Type = _
        xlConditionValueLowestValue
    With Selection.FormatConditions(1).ColorScaleCriteria(1).FormatColor
        .Color = 8109667
        .TintAndShade = 0
    End With
    Selection.FormatConditions(1).ColorScaleCriteria(2).Type = _
        xlConditionValuePercentile
    Selection.FormatConditions(1).ColorScaleCriteria(2).Value = 50
    With Selection.FormatConditions(1).ColorScaleCriteria(2).FormatColor
        .Color = 8711167
        .TintAndShade = 0
    End With
    Selection.FormatConditions(1).ColorScaleCriteria(3).Type = _
        xlConditionValueHighestValue
    With Selection.FormatConditions(1).ColorScaleCriteria(3).FormatColor
        .Color = 7039480
        .TintAndShade = 0
    End With
    

    【讨论】:

    • 我用的是2010,我看到了,效果很好,有没有看vba编码的?每次打开 Excel 时,我都喜欢将日期更改为今天
    • 它不使用 VBA - 它是内置的 Excel。要复制它,你可以使用这样的宏:
    【解决方案2】:

    您不需要 VBA 来执行此操作。在我看来,在这种特殊情况下,VBA 会使事情变得不必要地复杂化。 (这来自一个 VBA 爱好者。)

    这是 Excel 2003,但想法在 2010 年是一样的。

    【讨论】:

    • 为什么这被否决了?该死的,我讨厌人们不离开 cmets! +1 使用条件格式。我认为这是一起报复案件。您会在一分钟内获得 2 次无法解释的反对票(单独的线程)!
    • @SiddharthRout:感谢您的支持!是的,我也在考虑报复。有些人手头的时间太多了。
    • 赞成取消另一个反对票,因为这是一个很好的答案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-08-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-07
    • 2018-06-05
    相关资源
    最近更新 更多