Excel MATCH range without specific CELL

拜拜、爱过 提交于 2020-01-14 22:46:07

问题


after a deep search on the internet i gave up.

My "simple" question would be: How can I add two ranges in a formula, preferably in MATCH?

I want to search a range like A1:A7 + A9:A20 and thus not include A8 in my range.

Is this possible? Please help me out


回答1:


Natively you can't but you could try to bypass it with either:


Exclude a single cell:

If you want to exclude a certain cell from a MATCH you can exclude it's certain row number like so:

=MATCH(1,(A1:A20="X")*(ROW(A1:A20)<>8),0)

Or

=MATCH(1,INDEX((A1:A20="X")*(ROW(A1:A20)<>8),),0)

Both are array formulas but only the first one needs to be confirmed by holding down Ctrl+Shift before pressing Enter


Exclude a range of cells:

If you would want to exclude a range of rows, e.g. 8-12, then we cannot use the AND or OR logic as they don't return an array. However, we can mimic it ourselves like:

=MATCH(1,(A1:A20="x")*((ROW(A1:A20)<8)+(ROW(A1:A20)>12)),0)

Or

=MATCH(1,INDEX((A1:A20="x")*((ROW(A1:A20)<8)+(ROW(A1:A20)>12)),),0)

Where, again, both are array formulas but only the first one needs to be confirmed by holding down Ctrl+Shift before pressing Enter


Alternative

Alternatively, you could stack MATCH functions in a number of ways, but here is one of them:

=IFERROR(MATCH("x",A1:A7,0),MATCH("x",A13:A20,0))
  • Pro: No array formula > Fast!
  • Con: Will return a match's relative row position in either the first or second range. In this example you could just add 12 to the second result.

Good luck =)



来源:https://stackoverflow.com/questions/58084414/excel-match-range-without-specific-cell

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