Summing several columns based on criteria

dracer

Board Regular
Joined
Jul 30, 2014
Messages
76
Office Version
  1. 365
  2. 2019
If I have a dataset of 100 rows and 13 columns (1st column being the non numerical data-columns 2-13 would be numerical by month), I was wondering how I could get a formula to add several rows and columns at once based on the number of months. For example in January I would add Column 2 only and in Feb add columns 2&3 and add a column each month (based on the number of months-which would be part of the formula). I know this can be done if the data is all in one row however I was wondering if this can be done if the data is in many rows. For example if I had 30 rows of "ADL" as the criteria in March I would want to add all 30 rows in columns 2 3 and 4 (Jan-March). Does anyone have any ideas?
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
What version of Excel are you using? You should update your profile. Also, not sure how your data is entirely setup as far as rows with "ADL" for March, but does this look like what you're after?
Book1
ABCDEFGHIJKLM
1JanFebMarAprMayJunJulAugSepOctNovDec
2ADL624333397298
3ADL169689537732
4ADL61073354498410
5ABX5563510716813
6ABX33312104410752
7MNO2693411058242
8MNO1936595251015
9TUV955879998554
10XYZ912473343673
11
12ADL133151
Sheet2
Cell Formulas
RangeFormula
B12:D12B12=SUMPRODUCT(($A$2:$A$10=$A$12)*$B$2:B10)
 
Upvote 0
Thanks for responding. I'm using excel 365. That is how the data is laid out. The formula above is similar to a SUMIF. Based on your formula I would have it $B$2:$I$10 for August and $B$2:$J$10 for September. The question is how can I get it to automatically adjust to J10 and K10 automatically based on the date that I have in separate cell on a different worksheet i.e. the value in the cell is is 8/31/24 so it goes to J10 - 9/30/24 it would move to K10 with $B$2 being constant. I know this can be done with and Index:Index type of formula when all the data is in one row, but not when it's in many rows.
 
Upvote 0
Thanks for responding. I'm using excel 365. That is how the data is laid out. The formula above is similar to a SUMIF. Based on your formula I would have it $B$2:$I$10 for August and $B$2:$J$10 for September. The question is how can I get it to automatically adjust to J10 and K10 automatically based on the date that I have in separate cell on a different worksheet i.e. the value in the cell is is 8/31/24 so it goes to J10 - 9/30/24 it would move to K10 with $B$2 being constant. I know this can be done with and Index:Index type of formula when all the data is in one row, but not when it's in many rows.
Why does the date 8/31/24 mean looking through September(9/30/24)? And what are the exact values in row 1?
 
Upvote 0
Why does the date 8/31/24 mean looking through September(9/30/24)? And what are the exact values in row 1?
Sorry. My error. I meant to say 8/31/24 would go up to column I and 9/30/24 would go up to column J. The exact values in row 1 are 1/1/23, 2/1/23 ect formatted as Jan-23 and Feb-23 ect.
 
Upvote 0
Okay, something like this then, where O1 is the date on sheet 2:
Book1
ABCDEFGHIJKLMNO
1Jan-23Feb-23Mar-23Apr-23May-23Jun-23Jul-23Aug-23Sep-23Oct-23Nov-23Dec-238/31/2023
2ADL624333397298
3ADL169689537732
4ADL61073354498410
5ABX5563510716813
6ABX33312104410752
7MNO2693411058242
8MNO1936595251015
9TUV955879998554
10XYZ912473343673
11
12ADL122
Sheet3
Cell Formulas
RangeFormula
B12B12=SUM(FILTER(FILTER(B2:M10,(B1:M1<=O1)),A2:A10=A12))
 
Upvote 0
Solution
Okay, something like this then, where O1 is the date on sheet 2:
Book1
ABCDEFGHIJKLMNO
1Jan-23Feb-23Mar-23Apr-23May-23Jun-23Jul-23Aug-23Sep-23Oct-23Nov-23Dec-238/31/2023
2ADL624333397298
3ADL169689537732
4ADL61073354498410
5ABX5563510716813
6ABX33312104410752
7MNO2693411058242
8MNO1936595251015
9TUV955879998554
10XYZ912473343673
11
12ADL122
Sheet3
Cell Formulas
RangeFormula
B12B12=SUM(FILTER(FILTER(B2:M10,(B1:M1<=O1)),A2:A10=A12))
Thanks a Million!! This works. I understand what you did and will be able to use this concept for other analysis. I'm not really up to speed on the filter function, but will spend more time studying it.
 
Upvote 0
Thanks a Million!! This works. I understand what you did and will be able to use this concept for other analysis. I'm not really up to speed on the filter function, but will spend more time studying it.
You're welcome, and happy to help. I used a double FILTER because you can't do row and column in a single FILTER.
 
Upvote 0

Forum statistics

Threads
1,224,819
Messages
6,181,153
Members
453,021
Latest member
Justyna P

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