My array formula is counting blanks as zero - how do I differentiate?

lincolnshep

New Member
Joined
Nov 1, 2010
Messages
9
Hi,

I'm trying to find the row number of the last cell in an array that is equal to zero but is not blank. My array is one column wide and 38 rows deep (K6:K43). The top 1 to x rows will always have a value (0, 3, 5 or 7) and the bottom x+1 to 38 rows will always be blank.

I've tried:
{=MAX(IF(K6:K43=0,ROW(K6:K43)))} : this returns 43 (which suggests it's counting the blanks as zero)
{=MAX(IF(AND(K6:K43=0,K6:K43<>""),ROW(K6:K43)))} : this returns 0

I'm obviously missing something (I'm quite new to array formulae) so any help would be greatly appreciated.

Thanks and regards,
Shep
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Hello XOR LX,

{=MAX(IF(+K6:K43=0,ROW(K6:K43)))} is also returning 43 (i.e. the last blank in the range, rather than the last zero in the range) but, for my own interest, what does adding the "+" do to the formula?

Thanks,
Shep
 
Upvote 0
I'm trying to find the row number of the last cell in an array that is equal to zero but is not blank. My array is one column wide and 38 rows deep (K6:K43). The top 1 to x rows will always have a value (0, 3, 5 or 7) and the bottom x+1 to 38 rows will always be blank.
This?

=5+COUNT(K6:K43)
 
Upvote 0
{=MAX(IF(+K6:K43=0,ROW(K6:K43)))} is also returning 43 (i.e. the last blank in the range, rather than the last zero in the range)

Apologies. I made the assumption that your "blanks" were actually null strings, i.e. "".

Use:

=MAX(IF(ISNUMBER(K6:K43),IF(K6:K43=0,ROW(K6:K43))))

which will work no matter whether the blanks are "genuine" blanks or the null string "".

Regards
 
Upvote 0
Hi Peter,
I'm looking for cells that equal zero, COUNT will give me all cells with numbers regardless of value.
Thanks,
Shep
Yes, sorry, I misinterpreted your question.

If using Excel 2010 or later you could also try this non array-entered formula.

=AGGREGATE(14,6,ROW(K6:K43)/(0&K6:K43="00"),1)
 
Upvote 0
Yes, sorry, I misinterpreted your question.

If using Excel 2010 or later you could also try this non array-entered formula.

=AGGREGATE(14,6,ROW(K6:K43)/(0&K6:K43="00"),1)

Thank you Peter. I have not used AGGREGATE before, I will enjoy picking this apart to see what it does!

Shep
 
Upvote 0
Thank you Peter. I have not used AGGREGATE before, I will enjoy picking this apart to see what it does!

Shep
Glad to help.

FWIW a combination of mine & XOR LX's would give another quite short (array) formula for use in all versions:

{=MAX(ROW(K6:K43)*(0&K6:K43="00"))}
 
Upvote 0

Forum statistics

Threads
1,214,990
Messages
6,122,625
Members
449,093
Latest member
catterz66

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