• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User


  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Formula Challenge 020 - Conditional COUNT


Excel Ninja
I think this is easier one but saw this as requirement on some other forum. The person had requested a VBA solution as probably he thought VBA was easier [only?] route.

Here is the data:
Heading Col1 Col2 Col3 Col4 Col5 Col6 Col7 Col8 CC
    H1      12      0      0     0      0     -5     1      0    8
    H2        0      0     -7   12    13    15   16      4    6
    H3        1      0      0     0      0      0     0      0    8
    H4        0      1      0     1      0      1     0      1    7
There are 8 columns and correlate to some items which have numeric value under each column. The last column with name "CC" is the result column which shows expected result for the particular set of data.

There are no blanks and Text entries in the data field.
The numerical values are whole numbers.
Your formula may take these assumptions into account. Or you could work out some fantastic solution which works without these assumptions.

Your challenge is to find first non-zero occurrence and then give count for all columns ahead even if they have 0 or any other numeric value.
Note: the formula should work any where in the sheet.

I have not used named ranges but you can use them. I am interested in seeing your formula and thinking more than anything else. And try to work out array and non-array approaches. So far, I have figured out 2-3 approaches which work so I do have a solution with me.


Excel Ninja
Hi Shrivallabha,
There are many ways to solve this... so to kick things off, here is one approach:

entered with Ctrl + Shift + Enter


Haseeb A

Active Member
Hello Shri,

How about,


For compatible with all versions,


Both are Array.

Sam Mathai Chacko

Active Member
Keeping in line with Haseeb's hard-coded '9' columns, I'd suggest using this


However, to keep it flexible, I'll go with


similar to Sajan's approach

both CSE, and the assumption being there's at least 1 non-zero value in each row (in line with the original challenge)


Excel Ninja
Thank you for your replies guys. They are awesome approaches.

I am seeing the usual suspects here barring few. We all have grown fond with CSE and they are the ones which come to us very quickly. Here's one non-CSE idea which seems to work.


Sam: No worries man, you can post your formula with some additional assumptions. Remember, this is not a practical issue that we are dealing with. We are playing with the formulas.


Excel Rōnin
Hi, shrivallabha!
Another approach with array formula:
=9-COINCIDIR(1;ABS(SIGNO(B2:I2));0) -----> in english: =9-MATCH(1,ABS(SIGN(B2:I2)),0)


Excel Ninja
Good one, Faseeh.

Re-looking at the challenge is refreshing. Here's one more idea which works without CSE: