简体   繁体   English

Excel 中的反向匹配搜索

[英]Reverse Match Search in Excel

I need to do a match/index search in reverse right to left我需要从右到左反向进行匹配/索引搜索

each cell with have an xi need do go from right to left find what column the x is in and report the position so can then go to the top of that column and pull that data.每个有 xi 的单元格都需要从右到左找到 x 所在的列并报告位置,然后可以转到该列的顶部并提取该数据。 I basically need to find out what column is the last X in.我基本上需要找出最后一个 X 在哪一列。

A         B        C        D    E          F      G      H      I       J
State   27-Aug  28-Aug  29-Aug  30-Aug  31-Aug  1-Sep   2-Sep   3-Sep   4-Sep
VI       X        X       X        X       X      X     

in above example 3 rows 10 columns if i want to see that the last X is in Column G(7) then i use the index to go to that column(7), row A to 1-sep as the answer.在上面的示例中,3 行 10 列,如果我想看到最后一个 X 在 G(7) 列中,那么我使用索引转到该列(7),A 行到 1-sep 作为答案。

This will find the last cell with a value, regardless of value:这将找到具有值的最后一个单元格,而不管值如何:

=INDEX($A$1:$J$1,MATCH("zzz",A2:J2))

在此处输入图像描述


If you want to find the last X , regardless of what is or is not in any of the other cells, then use this formula:如果您想找到最后一个X ,无论其他单元格中是否存在什么,请使用以下公式:

=INDEX($A$1:$J$1,AGGREGATE(14,6,COLUMN(A2:J2)/(A2:J2="X"),1))

One note: this is an array type formula and will be slower than the prior formula.注意:这是一个数组类型的公式,会比之前的公式慢。 If you only have one it will not make a difference.如果你只有一个,它不会有所作为。 If you have hundreds you will see a difference.如果你有数百个,你会看到不同。

But if you have other text strings after the X and you want the X then it is the way to go.但是,如果您在X之后有其他文本字符串并且您想要X ,那么这是要走的路。

在此处输入图像描述

try out试用

=INDEX(1:1,1,COUNTIF(2:2,"X")-1) 

Assuming there are no gaps within the stream of X's假设 X 的流中没有间隙

=MATCH(2,IF(A2:J2="x",1,FALSE))

This is an array formula.这是一个数组公式。 This will give you last position of x.这将为您提供 x 的最后位置。 Then, like you indicated, put the result inside INDEX function and you should be good.然后,就像您指出的那样,将结果放入 INDEX 函数中,您应该会很好。 I like this option because i can put any condition inside the if statement, like >0.我喜欢这个选项,因为我可以在 if 语句中放置任何条件,例如 >0。

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

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