Sum One To Multiple Columns

goss

Active Member
Joined
Feb 2, 2004
Messages
372
Hi all,

Using Excel 2010.

I would like to be able to find the sum of a varying number of columns based on user defined criteria.

If user defines column 6, just colmn 6 (period end total)
If column 5 : sum(1-5)
If column 4 : sum(1-4)
And so forth...

My formula currently works for 1 column only. How may I adapt to variable columns per above?

=SUMPRODUCT((Data!$A$2:$A$2020=$B7)*(Data!$E$2:$E$2020=K$6)*(INDEX(Data!$F$2:$K$2020,0,MATCH(WK,Data!$F$1:$K$1,0))))

WK is a defined name on the setup tab where the user may enter 1-6
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Hi all,

Using Excel 2010.

I would like to be able to find the sum of a varying number of columns based on user defined criteria.

If user defines column 6, just colmn 6 (period end total)
If column 5 : sum(1-5)
If column 4 : sum(1-4)
And so forth...

My formula currently works for 1 column only. How may I adapt to variable columns per above?

=SUMPRODUCT((Data!$A$2:$A$2020=$B7)*(Data!$E$2:$E$2020=K$6)*(INDEX(Data!$F$2:$K$2020,0,MATCH(WK,Data!$F$1:$K$1,0))))

WK is a defined name on the setup tab where the user may enter 1-6
Try this...

=SUMPRODUCT((Data!$A$2:$A$2020=$B7)*(Data!$E$2:$E$2020=K$6)*(IF(WK=6,Data!$K$2:$K$2020,Data!$F$2:INDEX(Data!$F$2:$K$2020,0,MATCH(WK,Data!$F$1:$K$1,0)))))

I don't think you need that MATCH function. Try removing it and see if the formula does what you want without it.

=SUMPRODUCT((Data!$A$2:$A$2020=$B7)*(Data!$E$2:$E$20=K$6)*(IF(WK=6,Data!$K$2:$K$2020,Data!$F$2:INDEX(Data!$F$2:$K$2020,0,WK))))
 
Upvote 0
Thanks Biff,

I took out the MATCH and the formula returned #N/A.
As soon as I put put it back in, it worked great

Thanks for your help
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,849
Members
452,948
Latest member
UsmanAli786

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