Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
neda5
 
Posts: n/a
Default sum previous x number of cells

Based on the table bellow, I am trying to add all the numbers in colmn B
between two 1s in column A. To state it in anotger way, in column C every
time column A equals 1, I want to add the last x many cells of column B.
A B C
1 5 5
5 0
1 5 10
5 0
1 5 10
5 0
The problem is that the frequency at which the 1s in column A appear changes.
Is there a formula that would either tell cells in column C to add all the
values in column B since the last 1 in column A or alternatevely to tell the
cells in column C to add the last x number of cells in column B. I hope this
makes sense.
Thanks. Neda
  #2   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default sum previous x number of cells

C1: =IF(A1=1,B1,"")
C2: =IF(A2<1,"",SUM(INDIRECT("A"&MAX(IF($A$1:A1=1,ROW ($A$1:A1))))))

which is an array formula, it should be committed with Ctrl-Shift-Enter, not
just Enter. Copy C2 down.

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"neda5" wrote in message
...
Based on the table bellow, I am trying to add all the numbers in colmn B
between two 1s in column A. To state it in anotger way, in column C every
time column A equals 1, I want to add the last x many cells of column B.
A B C
1 5 5
5 0
1 5 10
5 0
1 5 10
5 0
The problem is that the frequency at which the 1s in column A appear

changes.
Is there a formula that would either tell cells in column C to add all the
values in column B since the last 1 in column A or alternatevely to tell

the
cells in column C to add the last x number of cells in column B. I hope

this
makes sense.
Thanks. Neda



  #3   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default sum previous x number of cells

C2 should be

=IF(A2<1,"",SUM(INDIRECT("B"&MAX(IF($A$1:A1=1,ROW ($A$1:A1)))&":B"&SUM(ROW()
))))

still an array formula.

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"Bob Phillips" wrote in message
...
C1: =IF(A1=1,B1,"")
C2: =IF(A2<1,"",SUM(INDIRECT("A"&MAX(IF($A$1:A1=1,ROW ($A$1:A1))))))

which is an array formula, it should be committed with Ctrl-Shift-Enter,

not
just Enter. Copy C2 down.

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"neda5" wrote in message
...
Based on the table bellow, I am trying to add all the numbers in colmn B
between two 1s in column A. To state it in anotger way, in column C

every
time column A equals 1, I want to add the last x many cells of column B.
A B C
1 5 5
5 0
1 5 10
5 0
1 5 10
5 0
The problem is that the frequency at which the 1s in column A appear

changes.
Is there a formula that would either tell cells in column C to add all

the
values in column B since the last 1 in column A or alternatevely to tell

the
cells in column C to add the last x number of cells in column B. I hope

this
makes sense.
Thanks. Neda





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Count number of cells that contain a certain letter - Case Sensitive elite Excel Discussion (Misc queries) 4 September 20th 05 01:41 PM
how to format only a specific character or number in each cell withina range of cells Colleen Excel Worksheet Functions 1 September 12th 05 05:44 PM
can I get cells with a minus number to show zero marcus1066 Excel Discussion (Misc queries) 3 May 7th 05 06:09 PM
cells changing from number to date [email protected] Excel Discussion (Misc queries) 1 March 22nd 05 04:31 PM


All times are GMT +1. The time now is 01:29 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"