Help! I need a "count until" function...

hedgeman50

Board Regular
Joined
Sep 20, 2002
Messages
76
Here's the setup: I have data in column A (A5:A64, to be exact). Column A has negative numbers and multiple zero values. In cell E19, I have: =MIN(A5:A64).

I need for cell E20 to be able to count back from the cell that had the min value from the equation in E19 (cell A28 in this case, but the cell could change when data is updated, so I don't want to hard-code that cell) to the most recent zero value (counting backward). I also need for the next cell, E21, to be a count of the number of cells after the result from the equation in E19 until a value of zero is reached (same as previous equation but counting forward instead of backward).

The equation would look something like this (but using correct formulas):

=count backward from (cell result in E19) until 0.00 is reached

How can this be done?

Thanks,
Hedgeman50
 
I have this equation for three sets of data in my spreadsheet. I just realized it's simply taking the first zero value in the column for each equation. That is, the 23 result I posted above represents the count from my value in $E4 to the FIRST zero value in the column--instead the first zero to precede the cell value in $E$4 (E28 in this case). The result (as you can see from the data posted) should be two--i.e., the first value of zero appeared two cells above E28.

Any ideas?

Thanks!

Max
 
Upvote 0

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Success! Thanks to both Sean and Yogi! I ended up going with the equations Sean entered, as I have many values of zero (as opposed to just one before the minimum figure). Also, though I doubt the lowest figure will ever be repeated, it's nice to have that functionality built-in.

You guys are Excel wizards. Thanks again. If you're ever in Manhattan Beach (California), lunch is on me.

Max
 
Upvote 0
Hi Max:

The formulation that I had provided earlier for the Backward Count will work if there was only one zero (0) in the Backward Count range -- otherwise for the Backward Count we have to do some additional work as shown in the following illustration ...
Book2
DEFGHIJ
4Intermediary Calculation
5-0.04680.00%
6-0.02560.00%
700.00%
8-0.01330.00%
90-2.84%-0.046828
1000.00%Backward Count2
1100.00%Forward Count1
12-0.00530.00%
13-0.0235-1.37%
1400.00%
1500.00%
1600.00%
1700.00%
1800.00%
1900.00%
20-0.0137-2.35%
210-0.53%
2200.00%
2300.00%
24-0.02840.00%
250-1.33%
2600.00%
270-2.56%
280-4.68%
Calculation Data


The additional formula in cells D5:D28 in the illustration is ...

=INDEX(E:E,$J$9+1-ROW(INDIRECT("1:"&$J$9)))

This is an array formula and is to be entered with CTRL+SHIFT+ENTER rather than with just ENTER.

I am going to look at simplifying this and see if we can avoid having to use thois additional column and the additional calculation.

I hope this helps.
 
Upvote 0
Hi Max:

Here is one without having to use the additional column and the associated calculation ...
Book2
EFGHIJ
1
2
3
4
50.00%
60.00%
70.00%
80.00%
9-2.84%-0.046828
100.00%Backward Count2
110.00%Forward Count1
120.00%
13-1.37%
140.00%
150.00%
160.00%
170.00%
180.00%
190.00%
20-2.35%
21-0.53%
220.00%
230.00%
240.00%
25-1.33%
260.00%
27-2.56%
28-4.68%
Calculation Data (2)


The formula in cell I10 is ... =$J$9-MAX(IF(INDIRECT("E5:E"&$J$9)=0,ROW(INDIRECT("5:"&$J$9))))

This is an array formula and is to be entered with CTRL+SHIFT+ENTER rather than with just ENTER.

Let me know how it works out when you put this formulation through various test runs.
 
Upvote 0
Yogi,

Your persistence knows no bounds. I like that.

Do you see any problem with Sean's equation? I have entered for the countback function:

{='Calculation data'!E4-LARGE(ROW('Calculation data'!E5:INDEX('Calculation data'!E:E,'Calculation data'!E4))*('Calculation data'!E5:INDEX('Calculation data'!E:E,'Calculation data'!E4)=0),1)}

(Sorry about the messiness of the references to another worksheet.)

It produces the correct results. Do you foresee a time when it wouldn't?

Max
 
Upvote 0
hedgeman50 said:
Yogi,
....
Do you see any problem with Sean's equation? I have entered for the countback function:

{='Calculation data'!E4-LARGE(ROW('Calculation data'!E5:INDEX('Calculation data'!E:E,'Calculation data'!E4))*('Calculation data'!E5:INDEX('Calculation data'!E:E,'Calculation data'!E4)=0),1)}

(Sorry about the messiness of the references to another worksheet.)
I have not worked with Sean's equation that you have posted here.
It produces the correct results.
That is what counts!
Do you foresee a time when it wouldn't?
Sorry -- wouldn't know!

Good Luck with your project!
 
Upvote 0

Forum statistics

Threads
1,214,951
Messages
6,122,449
Members
449,083
Latest member
Ava19

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