View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default How to sum x cells that are greater than zero on the right?

This array-entered** formula appears to work for your 3M condition...

=IF(COUNTIF(C4:Z4,"0")3,SUM(IF(COLUMN(C4:Z4)<=SM ALL(IF(C4:Z4<0,COLUMN(C4:Z4)),3),C4:Z4,0)),SUM(C4 :Z4))

Change the two occurrences of the number 3 to 12 for your 12M condition.

Note: You did not say what to do if there were more than 1 value but less
than the number being looked for (for example, 2 non-zero value for your 3M
condition)... I assumed you wanted to add what was there, hence the
SUM(C4:Z4) at the end of my formula... if you want to report something else
for this situation, then just change that part of the formula.

**Commit formula using CTRL+SHIFT+ENTER, not just Enter by itself

Rick Rothstein (MVP - Excel)






"Learn" wrote in message
...

Hi

I am finding a solution (formula) to automatically sum (3 or 12) cells
on the right after encountering first right cell greater than 0.

Currently, this is done manually. (eg. 3.8 is the sum of 2.9 (Aug) +
0.5 (Sep) + 0.4 (Oct).)

Question is there a way to do this automatically because there are
thousands of rows..and this will drive me crasy in maintaining this
worksheet effectively. Thanks.

First First
3M 12M Jul Aug Sep Oct Nov
Dec ....................
---------------------------------------------------------------------------
----------------------------------------------------------------
3.8 5.4 0.0 2.9 0.5 0.4 0.3
0.2 ....................
1.1 2.2 0.0 0.9 0.0 0.2 0.0
0.4 ....................
0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 ....................
4.1 5.2 0.0 0.0 0.0 1.9 1.3
0.9 ....................
3.1 5.1 0.0 0.0 0.0 0.5 1.7
0.9 ....................
2.6 3.9 0.0 0.0 0.0 0.4 1.1
1.1 ....................

Thanks.