简体   繁体   English

如果两个条件都满足,Excel 条件格式

[英]Excel conditional formatting if two condition satisfies

I have excel sheet, which has value stored as price in "D" column我有 excel 表,其值存储为“D”列中的价格

now, I want to highlight particular cell in column "D" which satisfies below 2 conditions现在,我想突出显示满足以下 2 个条件的“D”列中的特定单元格

  1. XFB9<=0.02
  2. which cell has highest value among cells that has fulfilled above condition (column "D")在满足上述条件的单元格中哪个单元格具有最高值(“D”列)

issue I find here in writing formula is, to define range Because, how do I define range to get highest value from that cell which fulfills no.我在这里发现的问题是,定义范围因为,我如何定义范围以从满足 no 的单元格中获得最大值。 1 condition?, because it varies time to time 1 个条件?,因为它不时变化

I have written following formula in conditional formatting for no.我在条件格式中写了以下公式。 1 condition 1个条件

=XFB9<=0.02

Kindly help with your solution on this issue, any help highly appriciated.请帮助您解决此问题,任何帮助都非常有用。

It may not necessarily be the best way to do this but it's a way I found.这可能不一定是最好的方法,但这是我发现的一种方法。 Instead of using conditional formatting this vba can do both.这个 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

Ok I found a Conditional Formatting solution.好的,我找到了条件格式解决方案。 Add a second condition with the formula:使用公式添加第二个条件:

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

Obviously you need to adjust the range.显然你需要调整范围。 The first A1 being the first cell in the range and then the fixed range for the other 2 sections.第一个 A1 是范围中的第一个单元格,然后是其他 2 个部分的固定范围。

This highlights the max value that also is <=0.02.这突出显示了也是 <=0.02 的最大值。

=AND($XFB9<=0.02,D9=AGGREGATE(14,6,D$9:D$100/($XFB$9:$XFB$100<=0.02),1))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM