跳过第一次出现的vlookup

问题描述 投票:0回答:3

我正在尝试使用 vlookup 进行条件格式化。问题是,如果 vlookup 的值不是我想要的值,我不知道如何跳过 vlookup 的第一次出现。

例如:

a      5
b      2
c      9
a      3    
d      4

这是一个表格,我在 A 列中查找值“a”,但如果 B 列中的值不是“3”,那么我想检查值“a”的第二次出现,然后重新检查值是否在B 列等于“3”。

我不知道我是否清楚,但欢迎任何帮助。谢谢!

我还尝试了组合索引和匹配。

excel excel-formula conditional-formatting
3个回答
0
投票

enter image description here

喜欢这样吗?你只需将过滤器和列结合起来,然后进行 VLookUp 即可。


0
投票

您可以使用索引和匹配。
这假设第一行是标题行。
它首先找到第一个匹配项并返回行号,然后连接返回的行号 +1 并从那里开始下一次搜索。

=INDEX(B:B,MATCH("a",INDIRECT(CONCATENATE("A",MATCH("a",A:A,0)+1,":A500")),0)+2)

有说明

=INDEX(B:B, // find value in column B
MATCH("a",  // find the second "a"
INDIRECT(   // Makes the concatenated range a real range
CONCATENATE("A", // concatenate A with the rownumber it finds the first "a" on
MATCH("a",A:A,0)+1, // +1 because start next search on the next row
":A500")),0 // ":A500" change this to suit your needs. What is the range you need to find the second item within
 )+2) // +2 because header row and because +1 in the previous search

enter image description here

编辑:
如果它只是您想要的行号,则从公式中删除 INDEX。

=MATCH("a",INDIRECT(CONCATENATE("A",MATCH("a",A:A,0)+1,":A500")),0)+2

0
投票

“我正在尝试使用 vlookup 进行条件格式化......”

如果您想进行条件格式设置,可以尝试以下操作:


  • 选择A列
  • 通过公式的新条件格式规则:

    =AND($A1="a",$B1=3)
    
  • 应用格式并应用

enter image description here

这将突出显示 A 列 =“a”且 B 列 = 3 的所有行


如果有几行符合条件,而您只想突出显示第一行,则可以尝试以下公式:

=ROW()=MATCH(1,($A$1:$A1="a")*($B$1:$B1=3),0)

enter image description here


当然,您可以将单元格引用分配给查找值,而不是这些变量,例如:

=ROW()=MATCH(1,($A$1:$A1=$C$1)*($B$1:$B1=$D$1),0)

enter image description here


在 B 列(其中 A 列为“a”)的第一个值未知的情况下;你可以尝试以下公式:

=ROW()=MATCH(1,($A$1:$A1="a")*($B$1:$B1<>INDEX($B:$B,MATCH("a",$A$1:$A1,0))),0)
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.