Sum upwards by a number of rows

Peter1973

Well-known Member
Joined
May 13, 2006
Messages
963
Office Version
  1. 365
I am trying to work out how to look in a cell and then look up to the top of the sheet in than column how many cells have the same value and sum the corresponding cells next to them data example below

[TABLE="width: 256"]
<colgroup><col width="64" span="4" style="width:48pt"> </colgroup><tbody>[TR]
[TD="width: 64"][/TD]
[TD="class: xl63, width: 64"]A[/TD]
[TD="class: xl63, width: 64"]B[/TD]
[TD="class: xl63, width: 64"]C[/TD]
[/TR]
[TR]
[TD="class: xl63"]1[/TD]
[TD="class: xl63"]WEST[/TD]
[TD="class: xl63"]3[/TD]
[TD="class: xl63"] [/TD]
[/TR]
[TR]
[TD="class: xl63"]2[/TD]
[TD="class: xl63"]EAST[/TD]
[TD="class: xl63"]2[/TD]
[TD="class: xl63"] [/TD]
[/TR]
[TR]
[TD="class: xl63"]3[/TD]
[TD="class: xl63"]WEST[/TD]
[TD="class: xl63"]4[/TD]
[TD="class: xl63"] [/TD]
[/TR]
[TR]
[TD="class: xl63"]4[/TD]
[TD="class: xl63"]WEST[/TD]
[TD="class: xl63"]2[/TD]
[TD="class: xl63"] [/TD]
[/TR]
[TR]
[TD="class: xl63"]5[/TD]
[TD="class: xl63"]WEST[/TD]
[TD="class: xl63"]1[/TD]
[TD="class: xl63"] [/TD]
[/TR]
[TR]
[TD="class: xl63"]6[/TD]
[TD="class: xl63"]EAST[/TD]
[TD="class: xl63"]5[/TD]
[TD="class: xl63"] [/TD]
[/TR]
[TR]
[TD="class: xl63"]7[/TD]
[TD="class: xl64"]WEST[/TD]
[TD="class: xl64"]TOTAL[/TD]
[TD="class: xl64"]10
[/TD]
[/TR]
</tbody>[/TABLE]

The answer would be 10 in this case as all the cells in A that = A7 the sum of the cells in B=10.
I can do this with a sumif but the location of the cells moves and there is more than 1 sum in the data but i need to to look upwards in all cells above and a sumif gives me a circular reference.

Any help appreciated
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
You could use OFFSET but it's volatile:


Book1
ABC
1WEST3
2EAST2
3WEST4
4WEST2
5WEST1
6EAST5
7WESTTOTAL10
Sheet1
Cell Formulas
RangeFormula
C7=SUMIF(OFFSET($A$1,0,0,ROW()-1),$A7,OFFSET($B$1,0,0,ROW()-1,1))


WBD
 
Upvote 0
Heres another couple of ways:

=SUMIFS($B$1:INDEX(B:B,ROWS($A$1:A7)-1,0),$A$1:INDEX(A:A,ROWS($A$1:A7)-1,0),A7)
=SUMIFS(INDIRECT("$B$1:B"&ROWS($A$1:A7)-1),INDIRECT("A1:A"&ROWS($A$1:A7)-1),A7)
 
Upvote 0

Forum statistics

Threads
1,223,723
Messages
6,174,113
Members
452,545
Latest member
boybenqn

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