Counting Values Backwards!

cguy3000

New Member
Joined
May 30, 2019
Messages
15
Alright folks!! I have searched and searched for this and I have found no solution to my problem anywhere on the interwebs!

So I have a list of data, simply just rows of numbers say,

2
3
7
4
4
0
1
2
0
3
42
1

I am trying to find a way for excel to start from the bottom of the data and count upwards until the number 0 is reached. So for example, for the data set I provided at the above I would need some sort of equation to give a value of 3 because there are 3 values until the last 0 is reached countin gfom the bottom up. And if 0 is in the most bottom spot in the data column then it would return a value of 0.

I thought some variation of the count or countif equations would do the trick but I have no idea how to get it to count backwards. An equation that I could have resting in its own cell and always be checking so as soon as I update the column then it would update iteself too inorder to incorporate the new value.


Thanks you all!
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
=match(9e+307,a:a ) - lookup(9e+307, row(a1:a12) / (a1:a12=0))
 
Last edited:
Upvote 0
So if I have data values from A98 to A344 what would that equation you have look like? I need it to be in a range as well and not the entire A column. Sorry I didnt mention that!
 
Upvote 0
When I do it for just those 12 values it works fine! However whever I change the range to A98 to A344 it gives me a value of 15 even though the most bottom cell is 0 so it should be returning a value of 0. Any ideas?
 
Upvote 0
Also, another issue I forgot to mention. Every week I will be adding a new blank row at the bottom of the data set as to continue draggin down the range for all my other equations to incorperate the new data point. Because if I reference the actual last point rather than the next empty cell then the range of the equation doesnt move with the continual adding of numbers and dates. So Id have to manually drag down the range which would defeat the purpose. Would a macro be better equiped to handle this?
 
Upvote 0
See if this does what you need


A
B
C
D
97
98
2​
LastZero position​
Result​
99
3​
9​
3​
100
7​
101
4​
102
4​
103
0​
104
1​
105
2​
106
0​
107
3​
108
42​
109
1​
110

Formula in C99
=LOOKUP(2,1/((A98:A10000=0)*(A98:A10000<>"")),ROW(A98:A10000)-ROW(A98)+1)

Formula in D99
=COUNTIFS(INDEX(A98:A1000,C99):A10000,"<>0",INDEX(A98:A10000,C99):A10000,"<>")

M.
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,693
Members
448,979
Latest member
DET4492

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