Counta

bh414

New Member
Joined
Oct 9, 2014
Messages
3
Hi,

I'm trying to create a dynamic formula that will apply to multiple tables with multiple minimums. Basically, I am trying to first identify the cell that holds the minimum, then count the cells from that minimum down the column, until the cell value becomes greater than 1. So far, I have the following formula:

=COUNTA(INDIRECT(ADDRESS(MATCH(MIN(C5:BK65),A:A,FALSE), MATCH(MIN(C5:BK65),4:4,FALSE))):K17)

The first part (beginning with Indirect), identifies the cell containing the minimum (K14), but I can't figure out how to structure the formula that would return K17. And it must be dynamic, as K14 and K17 will vary depending on which table is being read.

Any help is appreciated!
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Welcome to MrExcel!

Can you show us what your table looks like, and which cells you're trying to add in the COUNTA() ?

It's not clear why you say that K14 contains the minimum. If the first part of your formula returns K14, it means only that the minimum value occurs in row 14 of column A, and also in column K of row 4. The value in K14 could be anything?
 
Upvote 0
Welcome to MrExcel!

Can you show us what your table looks like, and which cells you're trying to add in the COUNTA() ?

It's not clear why you say that K14 contains the minimum. If the first part of your formula returns K14, it means only that the minimum value occurs in row 14 of column A, and also in column K of row 4. The value in K14 could be anything?

Sorry for the confusion, first time posting. I'm dealing with 20 different tables, all with minimums in different cells and with different count ranges. Below is an example of one of the tables. Column A and Row 1 serve to identify the minimums, and return FALSE if the minimum is not contained. It was a way to match things up for another formula in the same spreadsheet. But these values will also change table to table.

I need to find the minimum value, then count down the column from the minimum value until a cell reaches greater than or equal to 1. So in this example, the minimum is found in J11, and I need to COUNTA(J11:J14).

So far, I am able to find the minimum for the beginning of the count range. But I need a formula to identify J14, or the first value in the column >1, that is dynamic.

=COUNTA(INDIRECT(ADDRESS(MATCH(MIN(C3:O15),A:A,FALSE), MATCH(MIN(C3:O15),1:1,FALSE))):J14)

Thanks!

ABCDEFGHIJKLMNO
1FALSEFALSEFALSEFALSEFALSEFALSEFALSE0.9553972FALSEFALSEFALSEFALSEFALSE
2Date1/1/19902/1/19903/1/19904/1/19905/1/19906/1/19907/1/19908/1/19909/1/199010/1/199011/1/199012/1/19901/1/1991
3FALSE1/1/19900.985
4FALSE2/1/19900.9861.001
5FALSE3/1/19900.9851.0000.999
6FALSE4/1/19900.9800.9950.9940.995
7FALSE5/1/19901.0141.0301.0291.0301.035
8FALSE6/1/19901.0221.0371.0361.0371.0431.007
9FALSE7/1/19901.0311.0461.0451.0461.0511.0161.009
10FALSE8/1/19901.0031.0181.0171.0181.0230.9890.9810.973
110.9553979/1/19900.9851.0000.9980.9991.0050.9710.9640.9550.982
12FALSE10/1/19901.0011.0161.0141.0151.0210.9860.9790.9710.9981.016
13FALSE11/1/19901.0151.0301.0291.0301.0351.0000.9930.9841.0121.0301.014
14FALSE12/1/19901.0291.0441.0431.0441.0491.0141.0070.9981.0261.0451.0281.014
15FALSE1/1/19911.0481.0641.0631.0641.0691.0331.0261.0171.0451.0641.0481.0331.019

<tbody>
</tbody>
 
Upvote 0
Given a data range: MyRange, then

RowNo: =SUMPRODUCT(--(MyRange=MIN(MyRange))*ROW(MyRange))
ColNo: =SUMPRODUCT(--(MyRange=MIN(MyRange))*COLUMN(MyRange))

will give you the row number and column number respectively of the minimum.

And I think the result you're looking for will be:

=SUMPRODUCT(--(INDEX(MyRange,,1+ColNo-COLUMN(MyRange))<1),--(ROW(MyRange)>=RowNo))

But be careful, if there is more than one minimum, you will get an incorrect result. You can test for this using:

=COUNTIF(MyRange,MIN(MyRange))>1

If you're open to using VBA, a UDF approach could also be used.
 
Upvote 0
Given a data range: MyRange, then

RowNo: =SUMPRODUCT(--(MyRange=MIN(MyRange))*ROW(MyRange))
ColNo: =SUMPRODUCT(--(MyRange=MIN(MyRange))*COLUMN(MyRange))

will give you the row number and column number respectively of the minimum.

And I think the result you're looking for will be:

=SUMPRODUCT(--(INDEX(MyRange,,1+ColNo-COLUMN(MyRange))<1),--(ROW(MyRange)>=RowNo))

But be careful, if there is more than one minimum, you will get an incorrect result. You can test for this using:

=COUNTIF(MyRange,MIN(MyRange))>1

If you're open to using VBA, a UDF approach could also be used.

Thank you so much! This works perfectly. Could you please give a little explanation on the methodology?
 
Upvote 0
Thank you so much! This works perfectly. Could you please give a little explanation on the methodology?

Let's use a simpler example to illustrate:

Excel 2010
ABCD
1
2999
3970.8
4990.9
5
6Results:
7RowNo3
8ColNo4
9Count2

<tbody>
</tbody>
Sheet1



We're working with arrays. If you edit each formula using F2, and use F9 to evaluate each component, it will show something like:

RowNo:
=SUMPRODUCT(--(MyRange=MIN(MyRange))*ROW(MyRange))
=SUMPRODUCT(--({FALSE,FALSE,FALSE;FALSE,FALSE,TRUE;FALSE,FALSE,FALSE})*{2;3;4})
=SUMPRODUCT({0,0,0;0,0,1;0,0,0}*{2;3;4})
=SUMPRODUCT({0,0,0;0,0,3;0,0,0})
=3

and similar for ColNo.

Count:
ColNo = 4, but because MyRange starts in column 2, we want the 3rd column of MyRange, which is:
=INDEX(MyRange,,1+ColNo-COLUMN(MyRange))
={9;0.8;0.9}

(There's a bit of a fudge here .. COLUMN(MyRange) actually returns {2,3,4} but INDEX returns only the first column = 2).

So ... SUMPRODUCT(--(INDEX(MyRange,,1+ColNo-COLUMN(MyRange))<1),--(ROW(MyRange)>=RowNo))
=SUMPRODUCT(--({9;0.8;0.9}<1),--({2;3;4}>=RowNo))
=SUMPRODUCT(--({FALSE;TRUE;TRUE}),--({FALSE;TRUE;TRUE}))
=SUMPRODUCT({0;1;1},{0;1;1})
=2
 
Upvote 0

Forum statistics

Threads
1,216,073
Messages
6,128,644
Members
449,461
Latest member
kokoanutt

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