jerry12302
Active Member
- Joined
- Apr 18, 2005
- Messages
- 456
- Office Version
- 2010
- Platform
- Windows
My formula below, in range V5:V1004, returns the next non-zero value in column U. There are currently 1,000 rows of data, from U5 to U1004.
=INDEX(U5:U$1200,MATCH(TRUE,INDEX(U5:U$1200<>0,),0))
The formula works fine, it's copied down through column V next to the data, and always finds the next non-zero value between the row it's in through the last row of data.
I plugged 1200 for the last row in the formula, but if the data range grows beyond 1200 I would have to change it. I changed it to 10000, for a test, but someday it may even grow beyond 10000. The problem becomes a matter of slowing down the calculations if it's changed too high, 1,000,000 for example, and if I end up with several of these columns of formulas it wouldn't be practical to use very large numbers for the last row for this reason.
I decided to change the formula to use Indirect(Address instead, with a count of all used data in column U, so I would never have to worry about changing the formula to accommodate larger and larger data sets:
=INDEX(INDIRECT(ADDRESS(ROW(U5),COLUMN(U5))&":"&ADDRESS(ROW(U$4)+COUNT(U:U),COLUMN(U5))),MATCH(TRUE,INDEX(INDIRECT(ADDRESS(ROW(U5),COLUMN(U5))&":"&ADDRESS(ROW(U$4)+COUNT(U:U),COLUMN(U5)))<>0,),0))
The formula returns an error though, #N/A.
The address portion by itself works fine, if I test it =ADDRESS(ROW(U5),COLUMN(U5))&":"&ADDRESS(ROW(U$4)+COUNT(U:U),COLUMN(U5)) I get $U$5:$U$1004
I use Indirect(Address a lot for other purposes, =SUM(INDIRECT(ADDRESS(ROW(U5),COLUMN(U5))&":"&ADDRESS(ROW(U$4)+COUNT(U:U),COLUMN(U5)))) gives me the sum of all the values in column U for example, no problem.
Why can't I use it in the Index,Match context? I simply replaced U5:U$1200 with the Indirect(Address equivalent.
Is there another way to accomplish this without using VBA, and without using Array formulas?
=INDEX(U5:U$1200,MATCH(TRUE,INDEX(U5:U$1200<>0,),0))
The formula works fine, it's copied down through column V next to the data, and always finds the next non-zero value between the row it's in through the last row of data.
I plugged 1200 for the last row in the formula, but if the data range grows beyond 1200 I would have to change it. I changed it to 10000, for a test, but someday it may even grow beyond 10000. The problem becomes a matter of slowing down the calculations if it's changed too high, 1,000,000 for example, and if I end up with several of these columns of formulas it wouldn't be practical to use very large numbers for the last row for this reason.
I decided to change the formula to use Indirect(Address instead, with a count of all used data in column U, so I would never have to worry about changing the formula to accommodate larger and larger data sets:
=INDEX(INDIRECT(ADDRESS(ROW(U5),COLUMN(U5))&":"&ADDRESS(ROW(U$4)+COUNT(U:U),COLUMN(U5))),MATCH(TRUE,INDEX(INDIRECT(ADDRESS(ROW(U5),COLUMN(U5))&":"&ADDRESS(ROW(U$4)+COUNT(U:U),COLUMN(U5)))<>0,),0))
The formula returns an error though, #N/A.
The address portion by itself works fine, if I test it =ADDRESS(ROW(U5),COLUMN(U5))&":"&ADDRESS(ROW(U$4)+COUNT(U:U),COLUMN(U5)) I get $U$5:$U$1004
I use Indirect(Address a lot for other purposes, =SUM(INDIRECT(ADDRESS(ROW(U5),COLUMN(U5))&":"&ADDRESS(ROW(U$4)+COUNT(U:U),COLUMN(U5)))) gives me the sum of all the values in column U for example, no problem.
Why can't I use it in the Index,Match context? I simply replaced U5:U$1200 with the Indirect(Address equivalent.
Is there another way to accomplish this without using VBA, and without using Array formulas?