Sum row range based on column header criteria

jtfish

New Member
Joined
Sep 29, 2023
Messages
5
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
1695990839709.png


I'm trying to figure out how to do the following when the above sales chart can be dynamic, meaning months can be added to the end, or even at the beginning, as more sales data is entered. If the user inputs a salesperson's name (Chris in the above example) and the range of months that they want sales totals for, it will return the sum of that range (275 + 375 + 425 + 500 in the above example) AND all sales through the end date starting with the very first month in the chart, whatever that month may be (400 + 265 + 275 + 375 + 425 + 500 in the above example). I've tried to do this using INDEX and MATCH, SUMPRODUCT, SUMIF and INDEX, SUMPRODUCT etc. but I can't quite get it to work. I've even tried using a helper row that returns the column number (using MATCH) of the chosen begin and end months, so I'm not opposed to using a helper row (above the year row for example) if that makes it easier to manage.

Is there a way to do this? Any help is greatly appreciated.
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
View attachment 99508

I'm trying to figure out how to do the following when the above sales chart can be dynamic, meaning months can be added to the end, or even at the beginning, as more sales data is entered. If the user inputs a salesperson's name (Chris in the above example) and the range of months that they want sales totals for, it will return the sum of that range (275 + 375 + 425 + 500 in the above example) AND all sales through the end date starting with the very first month in the chart, whatever that month may be (400 + 265 + 275 + 375 + 425 + 500 in the above example). I've tried to do this using INDEX and MATCH, SUMPRODUCT, SUMIF and INDEX, SUMPRODUCT etc. but I can't quite get it to work. I've even tried using a helper row that returns the column number (using MATCH) of the chosen begin and end months, so I'm not opposed to using a helper row (above the year row for example) if that makes it easier to manage.

Is there a way to do this? Any help is greatly appreciated.
Welcome to MrExcel.

What version of Excel are you actually using?

It would be a lot easier if instead of going across the worksheet you went down with columns as follows:

Name
Date
Value

Use the first of the month.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0
here's a solution for 365 w/ 2 helper rows added, hope this helps
---------------------
Book1
ABCDEFGHIJKL
1by name400265275375425500305
2dates10/1/202211/1/202212/1/20221/1/20232/1/20233/1/20234/1/2023
3year2022202220222023202320232023
4month1011121234salespersonchris
5bob210330250360420500240
6sam325260510375125330200beginend
7chris400265275375425500305year20222023
8mary365295415355270300500month123
9jane245450320310400215300
10answer 11575within range
11answer 22240through end year/month
Sheet1
Cell Formulas
RangeFormula
B1:H1B1=FILTER(B5:H9,A5:A9=K4)
B2:H2B2=DATE(B3:H3,B4:H4,1)
K10K10=SUMIFS(B1#,B2#,">="&DATE(K7,K8,1),B2#,"<="&DATE(L7,L8,1))
K11K11=SUMIFS(B1#,B2#,">="&DATE(1900,1,1),B2#,"<="&DATE(L7,L8,1))
Dynamic array formulas.
 
Upvote 0
MrExcel Example.xlsx
ABCDEFGHIJKLM
1Year:2022202220222023202320232023
2Month:1011121234SalespersonChris
3Bob210330250360420500240
4Sam325260510375125330200 Begin End
5Chris400265275375425500305Year20222023
6Mary365295415355270300500Month123
7Jane245450320310400215300
8Answer1,575(within above range)
9Answer2,240(through end year/month)
Sheet1


Herakles - Here's the data in XL2BB format. I use Excel version Home and Business 2019 at work and Office 365 at home. I really need this to work in 365 and non-365 versions because users could be using any Excel version. The example I posted here is a very simplified version of my actual worksheet just for illustriative purposes. I could have up to 10K salespeople and my resulting report will need to list salespeople in the left-most column. I suppose I could covert the data as you suggest but I'd need to convert it back after calculating the sales totals.

ExceLoki - I believe this will work but don't believe the hash(#) will work in non-365 versions.
 
Upvote 0
then you could just update the formula to use the range:
multiple posts solutions-v3.xlsm
JKL
10answer 11575within range
11answer 22240through end year/month
sum row range fromdate and name
Cell Formulas
RangeFormula
K10K10=SUMIFS(B1:H1,B2:H2,">="&DATE(K7,K8,1),B2:H2,"<="&DATE(L7,L8,1))
K11K11=SUMIFS(B1:H1,B2:H2,">="&DATE(1900,1,1),B2:H2,"<="&DATE(L7,L8,1))
 
Upvote 0
Solution
That works! Sorry, I didn't realize that's all the hash did. Thanks for your help. Extremely appreciated.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,154
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