且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何找到&返回未知范围内的所有非零值?

更新时间:2022-10-19 17:33:09

Try this in some column:

=IFERROR(INDEX($U:$U,SMALL(ROW(myRange)*(myRange<>0),SUMPRODUCT(N(myRange=0))+ROWS($1:1))),"")

This is an array formula and must be confirmed by holding down ctrl + shift while hitting enter

Enter it in some cell. See that it returns the desired value, then fill down until it returns blanks.

myRange is some arbitrary range larger than your largest row size. I used u38:u20000

EDIT: To return values from a matching row in a different column than U, merely change the array argument in the INDEX function from $U:$U to the desired column, eg: $AG:$AG

EDIT2: If you need to ignore error values in column U, try this CSE entered formula:

=IFERROR(INDEX(U:U,SMALL(ROW(myRange)*(IFERROR(--myRange,0)<>0),SUMPRODUCT(N(IFERROR(--myRange,0)=0))+ROWS($1:1))),"")