【问题标题】:Excel conditional formatting if two condition satisfies如果两个条件满足,则 Excel 条件格式
【发布时间】:2020-09-19 08:38:26
【问题描述】:

我有 excel 表,它的值存储为“D”列中的价格

现在,我想突出显示“D”列中满足以下 2 个条件的特定单元格

  1. XFB9<=0.02
  2. 在满足上述条件的单元格中哪个单元格的值最高(“D”列)

我在这里写公式时发现的问题是,定义范围 因为,我如何定义范围以从满足否的单元格中获得最高值。 1个条件?,因为它不时变化

我已经用条件格式写了以下公式。 1 个条件

=XFB9<=0.02

请帮助您解决此问题,任何帮助都非常感谢。

【问题讨论】:

  • Thank you so much for putting efforts and giving time, but I prefer conditional formating – Aman Patel 22 mins ago 标签已编辑以反映这一点。

标签: excel excel-formula conditional-formatting


【解决方案1】:

这可能不一定是最好的方法,但这是我找到的一种方法。这个 vba 可以同时使用这两种格式,而不是使用条件格式。

Dim rng As Range, cell As Range, previouscell As Variant

Set rng = Sheet1.Range("F22:F61") 'set your range

For Each cell In rng
    If cell.Value <= 0.02 Then
        cell.Interior.Color = vbYellow 'color for the values <=0.02
        If cell.Value > previouscell Then
            previouscell = cell.Value
        End If
    End If
Next

For Each cell In rng
    If cell.Interior.ColorIndex > 0 Then
        If cell.Value = previouscell Then
            cell.Interior.Color = vbRed 'color for max value
        End If
    End If
Next

好的,我找到了条件格式解决方案。使用公式添加第二个条件:

=A1=MAX(IF($A$1:$A$20<=0.02,$A$1:$A$20))

显然您需要调整范围。第一个 A1 是范围中的第一个单元格,然后是其他 2 个部分的固定范围。

这会突出显示也是

【讨论】:

  • 非常感谢您付出的努力和时间,但我更喜欢条件格式
  • 那为什么你的标签里有VBA呢?
  • @AmanPatel 我已经更新了条件格式答案。
【解决方案2】:
=AND($XFB9<=0.02,D9=AGGREGATE(14,6,D$9:D$100/($XFB$9:$XFB$100<=0.02),1))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-08
    • 2016-06-08
    • 2015-11-03
    • 2021-02-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多