Excel Reverse Match

孤街醉人 提交于 2019-12-23 03:02:13

问题


I'm trying to find a way to do a reverse match in Excel. I have a column of TRUE/FALSE statements and I need to find a way to find both a match and a reverse match within this one column to find the difference between TRUE statements in both directions.

True
False
False
False
True
False
False
True

In this scenario from the perspective of the middle True statement the normal MATCH function going down would return a number of 4. I am trying to find an additional match function that would look upward to the TRUE statement and return a value of 5


回答1:


Quick and dirty:

A1:A7: TRUE/FALSE
A8: Array formula: {=LARGE(IF(A1:A7=TRUE;ROW(A1:A7);"");1)}

The result will be the row number of the nearest TRUE from below. The formula is inserted by Shift-Ctrl-Enter in a formula window. Curled brackets are inserted by Excel, not by a user.

If you need the shift from the last TRUE: {=LARGE(IF(A1:A7=TRUE;ROW(A1:A7);"");2)}

Changing the last number in the formula moves you to the n-th TRUE from below.

Replacing LARGE with SMALL will give the row numbers from above. So it would possible to find the shift between relevant combinations by combining the formulae.



来源:https://stackoverflow.com/questions/14189085/excel-reverse-match

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!