Sumifs on dynamic rows / columns

dmessmer

New Member
Joined
Mar 27, 2017
Messages
6
Hello, I'm trying to do either a sumifs or index(match() in order to sum a range of cells (multiple columns and rows) based upon a reference cell which can be modified to adjust the number of columns which are summed. For example, in the below table on the right are my results. Since A1 is 3 months, the fruit totals are summing columns B,C, & D so long as it's the appropriate type of fruit.

3Months
Fruit
1/1/2017
2/1/2017
3/1/2017
4/1/2017Fruit
Total
Apple10467Apple20
Banana3815Banana12
Orange2573Orange14

<tbody>
</tbody>


If my variable was 4 months the results would look like:
4Months
Fruit
1/1/2017
2/1/2017
3/1/2017
4/1/2017Fruit
Total
Apple10467Apple27
Banana3815Banana17
Orange2573Orange17

<tbody>
</tbody>

Any suggestions on how to sum up the totals of ranges based upon a reference cells which makes your range dynamic? Thanks for the help!
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

<tbody>
</tbody>


A
B
C
D
E
F
G
H
1
3​
Months
2
3
Fruit
1/1/2017
2/1/2017
3/1/2017
4/1/2017
FruitTotal
4
Apple
10​
4​
6​
7​
Apple
20​
5
Banana
3​
8​
1​
5​
Banana
12​
6
Orange
2​
5​
7​
3​
Orange
14​

<tbody>
</tbody>


H4=SUMPRODUCT((MONTH($B$3:$E$3)<=$A$1)*($A$4:$A$6=$G4)*($B$4:$E$6)) copy down

for months 4 change 3 to 4 in a1

 
Last edited:
Upvote 0
Just an option. Needed to be pasted H4

Code:
=+SUMPRODUCT((G4=$A$4:$A$6)*INDEX($B$4;;):OFFSET($B$4;2;$A$1))


Hello, I'm trying to do either a sumifs or index(match() in order to sum a range of cells (multiple columns and rows) based upon a reference cell which can be modified to adjust the number of columns which are summed. For example, in the below table on the right are my results. Since A1 is 3 months, the fruit totals are summing columns B,C, & D so long as it's the appropriate type of fruit.

3Months
Fruit
1/1/2017
2/1/2017
3/1/2017
4/1/2017Fruit
Total
Apple10467Apple20
Banana3815Banana12
Orange2573Orange14

<tbody>
</tbody>


If my variable was 4 months the results would look like:
4Months
Fruit
1/1/2017
2/1/2017
3/1/2017
4/1/2017Fruit
Total
Apple10467Apple27
Banana3815Banana17
Orange2573Orange17

<tbody>
</tbody>

Any suggestions on how to sum up the totals of ranges based upon a reference cells which makes your range dynamic? Thanks for the help!
 
Last edited:
Upvote 0
Thanks for the quick reply, Marziotullio. I thought that by posting a pretty simple example I'd be able to use the help & apply it to my bit more complex problem. Unfortunately I am unable to do so. Let me elaborate.

My scenario is:

ABCDEFGHIJKLMNOPQRSTUV
13MonthsResults
2Fruit1/20172/20173/20174/20175/20176/20177/20178/20179/201710/201711/201712/20171/20182/20183/20181/20172/20173/20174/20175/20176/2017Etc.
3Apple10467837111412579210201721181821
4Banana89631147105763784231820182221
5Orange35789641071047637152024231920

<tbody>
</tbody>

I think that the original solution you've provided my be stopped by the fact that I have multiple years and therefore many of the same month. Additionally, in my results I need it to reference the month in it's own column. So for example, Q3 will add 2 additional months to 1/2017 and therefore will sum(A3,B3,C3). Then R3 would sum(B3,C3,D3), etc.

Can you original solution be modified to accommodate this?
 
Upvote 0

Forum statistics

Threads
1,215,078
Messages
6,122,997
Members
449,093
Latest member
masterms

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