Value of 1 column before the last value in a contiguous range

hsandeep

Well-known Member
Joined
Dec 6, 2008
Messages
1,226
Office Version
  1. 2010
Platform
  1. Windows
  2. Mobile
I am having K15:W15 which generates either a numerical number which is non zero or non blank; 0; blank.

I want an excel formula to get non zero and non blank value lying in the cell which should be 1 column before the last non zero non empty value of K15:W15.
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
One of possible answers could be:
Excel Formula:
=INDEX(15:15,1,MAX(IF((K15:W15=0)+(K15:W15=""),"",COLUMN(K15:W15)))-1)
and two comments:
* Are you still using Excel 2010 as mentioned in your profile?
If not, please adjust your profile in https://www.mrexcel.com/board/account/
* It could be that in older versions of Excel you shall commit this formula as an array one. So if you are not getting expected result set as active cell the cell with the formula. Press F2 to get into editing of formula and commit it not just with Enter, bur with Ctrl+Shift+Enter
 
Upvote 0
One of possible answers could be:
Excel Formula:
=INDEX(15:15,1,MAX(IF((K15:W15=0)+(K15:W15=""),"",COLUMN(K15:W15)))-1)
and two comments:
* Are you still using Excel 2010 as mentioned in your profile?
If not, please adjust your profile in https://www.mrexcel.com/board/account/
* It could be that in older versions of Excel you shall commit this formula as an array one. So if you are not getting expected result set as active cell the cell with the formula. Press F2 to get into editing of formula and commit it not just with Enter, bur with Ctrl+Shift+Enter
I think The better solution would be to use
Excel Formula:
=IFERROR(INDEX(K15:W15, SMALL(IF((K15:W15<>0), COLUMN(K15:W15)-COLUMN(K15)+1), COUNTIF(K15:W15,"<>0")-1)), 0)
Comments please.
 
Upvote 0
Why shall it be better? Have you tested both?
And again: what is your Excel version (may be in Ex 2010 calculations on large ranges were not that well optimized, so a minor sub-version could be a bit quicker, especially if you had to use array commitment):
Excel Formula:
=INDEX(A15:W15,1,MAX(IF((K15:W15=0)+(K15:W15=""),"",COLUMN(K15:W15)))-1)
Have a look also on yet another modification:
Excel Formula:
=INDEX(A15:W15,1,MAX(IF(K15:W15<>0,COLUMN(K15:W15),""))-1)
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top