Excel equation to find last non-zero value in column (must look at all the values in column)

cching

New Member
Joined
Apr 20, 2016
Messages
20
Hello,

I currently have an equation that will give me the last non-zero value in the column. However, my equation works by looking through the column from the top, and once it sees a 0 it will stop and output the value above it instead of going through the entire list.

Example

[TABLE="width: 133"]
<colgroup><col><col></colgroup><tbody>[TR]
[TD]Column A[/TD]
[TD]Column B[/TD]
[/TR]
[TR]
[TD="align: right"]1[/TD]
[TD="align: right"]11[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD="align: right"]11[/TD]
[/TR]
[TR]
[TD="align: right"]3[/TD]
[TD="align: right"]10[/TD]
[/TR]
[TR]
[TD="align: right"]4[/TD]
[TD="align: right"]9[/TD]
[/TR]
[TR]
[TD="align: right"]5[/TD]
[TD="align: right"]8[/TD]
[/TR]
[TR]
[TD="align: right"]6[/TD]
[TD="align: right"]7[/TD]
[/TR]
[TR]
[TD="align: right"]7[/TD]
[TD="align: right"]6[/TD]
[/TR]
[TR]
[TD="align: right"]8[/TD]
[TD="align: right"]5[/TD]
[/TR]
[TR]
[TD="align: right"]9[/TD]
[TD="align: right"]4[/TD]
[/TR]
[TR]
[TD="align: right"]10[/TD]
[TD="align: right"]3[/TD]
[/TR]
[TR]
[TD="align: right"]11[/TD]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD="align: right"]12[/TD]
[TD="align: right"]1[/TD]
[/TR]
[TR]
[TD="align: right"]13[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD="align: right"]14[/TD]
[TD="align: right"]8[/TD]
[/TR]
[TR]
[TD="align: right"]15[/TD]
[TD="align: right"]8[/TD]
[/TR]
[TR]
[TD="align: right"]16[/TD]
[TD="align: right"]8[/TD]
[/TR]
[TR]
[TD="align: right"]17[/TD]
[TD="align: right"]8[/TD]
[/TR]
[TR]
[TD="align: right"]18[/TD]
[TD="align: right"]8[/TD]
[/TR]
[TR]
[TD="align: right"]19[/TD]
[TD="align: right"]8[/TD]
[/TR]
[TR]
[TD="align: right"]20[/TD]
[TD="align: right"]12[/TD]
[/TR]
[TR]
[TD="align: right"]21[/TD]
[TD="align: right"]13[/TD]
[/TR]
[TR]
[TD="align: right"]22[/TD]
[TD="align: right"]12[/TD]
[/TR]
[TR]
[TD="align: right"]23[/TD]
[TD="align: right"]13[/TD]
[/TR]
[TR]
[TD="align: right"]24[/TD]
[TD="align: right"]12[/TD]
[/TR]
[TR]
[TD="align: right"]25[/TD]
[TD="align: right"]13[/TD]
[/TR]
[TR]
[TD="align: right"]26[/TD]
[TD="align: right"]13[/TD]
[/TR]
[TR]
[TD="align: right"]27[/TD]
[TD="align: right"]13[/TD]
[/TR]
[TR]
[TD="align: right"]28[/TD]
[TD="align: right"]13[/TD]
[/TR]
[TR]
[TD="align: right"]29[/TD]
[TD="align: right"]13[/TD]
[/TR]
[TR]
[TD="align: right"]30[/TD]
[TD="align: right"]13[/TD]
[/TR]
[TR]
[TD="align: right"]31[/TD]
[TD="align: right"]13[/TD]
[/TR]
[TR]
[TD="align: right"]32[/TD]
[TD="align: right"]13[/TD]
[/TR]
[TR]
[TD="align: right"]33[/TD]
[TD="align: right"]13[/TD]
[/TR]
[TR]
[TD="align: right"]34[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD="align: right"]35[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD="align: right"]36[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD="align: right"]37[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD="align: right"]38[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD="align: right"]39[/TD]
[TD="align: right"]0[/TD]
[/TR]
</tbody>[/TABLE]

The equation i have is

=INDEX(B2:B40,MATCH(0,B2:B40,0)-1)

which will output "1" since it found the "0" at row 13, and outputted the value in row 12.

How to I get it so that it will look through the entire column and output the last non-zero value, in this case, it should be "13"

Thanks
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

Forum statistics

Threads
1,223,275
Messages
6,171,122
Members
452,381
Latest member
Nova88

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