Sum column according to header and matched value

thanksamillion101

New Member
Joined
Jul 8, 2020
Messages
41
Office Version
  1. 2010
Hello and thank you ahead of time! I am needing to sum columns according to specified header names, reason being that I cannot specify a column range because the amount of columns may change when I run a report, but header names will remain the same. I need a formula to sum the amount of Units of Product "I" sold in TX with an Id of 375 between (Id 1) 350 and (Id 2) 400. The answer is 4.0 I have tried several formulas and now I am not sure which formula to use, sumif and index and match. Please help!

INDEX(A2:G7,MATCH("I",INDEX(A2:G7,MATCH("Product",A1:G1,0),),0))

ABCDEFG
1DateId 1Id 2NameProductUnitsState
21/1/2022100200SamAG2.5KS
33/4/2021600700TimEZ1.3OK
45/6/2021350400JohnI4TX
51/7/2021500700SamAG7.5KS
63/4/2022250400TimEZ6OK
75/1/2022600705JohnI8TX
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
I don't understand what you mean by "between (Id1) 350 and (Id2) 400". Do you mean Id1=350 and Id2=400?
MrExcel_20220803.xlsx
ABCDEFGHIJ
1ID lower350
2DateId 1Id 2NameProductUnitsStateID upper400
31/1/2022100200SamAG2.5KSProductI
43/4/2021600700TimEZ1.3OKSum4
55/6/2021350400JohnI4TX
61/7/2021500700SamAG7.5KS
73/4/2022250400TimEZ6OK
85/1/2022600705JohnI8TX
Sheet2
Cell Formulas
RangeFormula
J4J4=SUMIFS($F$3:$F$8,$B$3:$B$8,$J$1,$C$3:$C$8,$J$2,$E$3:$E$8,$J$3)
 
Upvote 0
I don't understand what you mean by "between (Id1) 350 and (Id2) 400". Do you mean Id1=350 and Id2=400?
MrExcel_20220803.xlsx
ABCDEFGHIJ
1ID lower350
2DateId 1Id 2NameProductUnitsStateID upper400
31/1/2022100200SamAG2.5KSProductI
43/4/2021600700TimEZ1.3OKSum4
55/6/2021350400JohnI4TX
61/7/2021500700SamAG7.5KS
73/4/2022250400TimEZ6OK
85/1/2022600705JohnI8TX
Sheet2
Cell Formulas
RangeFormula
J4J4=SUMIFS($F$3:$F$8,$B$3:$B$8,$J$1,$C$3:$C$8,$J$2,$E$3:$E$8,$J$3)
I don't understand what you mean by "between (Id1) 350 and (Id2) 400". Do you mean Id1=350 and Id2=

The sum amount is for the amount of Units of Product "I" sold in TX by and employee whose Id is "375", so the formula would specify needing to match the range falling in between (Id 1) 350 and (Id 2) 400. Hope that is a better explanation
 
Upvote 0
I don't understand what you mean by "between (Id1) 350 and (Id2) 400". Do you mean Id1=350 and Id2=400?
MrExcel_20220803.xlsx
ABCDEFGHIJ
1ID lower350
2DateId 1Id 2NameProductUnitsStateID upper400
31/1/2022100200SamAG2.5KSProductI
43/4/2021600700TimEZ1.3OKSum4
55/6/2021350400JohnI4TX
61/7/2021500700SamAG7.5KS
73/4/2022250400TimEZ6OK
85/1/2022600705JohnI8TX
Sheet2
Cell Formulas
RangeFormula
J4J4=SUMIFS($F$3:$F$8,$B$3:$B$8,$J$1,$C$3:$C$8,$J$2,$E$3:$E$8,$J$3)
I cannot use a column range and needing to match column headers because the column locations will change when I run a report, but header names will always remain the same.
 
Upvote 0
Sorry...I missed the point about not knowing a specific range. Here is an idea that requires you to specify a large range where the columns will be found...and then using INDEX/MATCH to return each column of interest, wherever they might be in that range. But I still don't understand the Id1 and Id2 point. The formula below requires Id1=350 and Id2=400. What does Id1 and Id2 mean? Are those the upper and lower limits for Id's to be considered, so that someone with an Id of 375 would be included? Where are the Id numbers associated with each "Name" found?
MrExcel_20220803.xlsx
ABCDEFGHIJKL
1DateId 1Id 2NameProductUnitsStateID lower350
21/1/2022100200SamAG2.5KSID upper400
33/4/2021600700TimEZ1.3OKProductI
45/6/2021350400JohnI4TXStateTX
51/7/2021500700SamAG7.5KSSum4
63/4/2022250400TimEZ6OK
75/1/2022600705JohnI8TX
Sheet2
Cell Formulas
RangeFormula
L5L5=SUMPRODUCT(INDEX($A$2:$I$99,,MATCH("Units",$A$1:$I$1,0)),(INDEX($A$2:$I$99,,MATCH("Product",$A$1:$I$1,0))=$L$3)*(INDEX($A$2:$I$99,,MATCH("State",$A$1:$I$1,0))=$L$4)*(INDEX($A$2:$I$99,,MATCH("Id 1",$A$1:$I$1,0))=$L$1)*(INDEX($A$2:$I$99,,MATCH("Id 2",$A$1:$I$1,0))=$L$2) )
 
Upvote 0
Sorry...I missed the point about not knowing a specific range. Here is an idea that requires you to specify a large range where the columns will be found...and then using INDEX/MATCH to return each column of interest, wherever they might be in that range. But I still don't understand the Id1 and Id2 point. The formula below requires Id1=350 and Id2=400. What does Id1 and Id2 mean? Could some row have an Id1 of 375?...if so, should it be considered?
MrExcel_20220803.xlsx
ABCDEFGHIJKL
1DateId 1Id 2NameProductUnitsStateID lower350
21/1/2022100200SamAG2.5KSID upper400
33/4/2021600700TimEZ1.3OKProductI
45/6/2021350400JohnI4TXStateTX
51/7/2021500700SamAG7.5KSSum4
63/4/2022250400TimEZ6OK
75/1/2022600705JohnI8TX
Sheet2
Cell Formulas
RangeFormula
L5L5=SUMPRODUCT(INDEX($A$2:$I$99,,MATCH("Units",$A$1:$I$1,0)),(INDEX($A$2:$I$99,,MATCH("Product",$A$1:$I$1,0))=$L$3)*(INDEX($A$2:$I$99,,MATCH("State",$A$1:$I$1,0))=$L$4)*(INDEX($A$2:$I$99,,MATCH("Id 1",$A$1:$I$1,0))=$L$1)*(INDEX($A$2:$I$99,,MATCH("Id 2",$A$1:$I$1,0))=$L$2) )
Id1 is a start of a batch and id 2 is the end of a batch, so if I need to find a specified id of 375, the formula would specify Id <400 and > 350.
 
Upvote 0
Try this...
MrExcel_20220803.xlsx
ABCDEFGHIJKL
1DateId 1Id 2NameProductUnitsStateFilters
21/1/2022100200SamAG2.5KSID375
33/4/2021600700TimEZ1.3OKProductI
45/6/2021350400JohnI4TXStateTX
51/7/2021500700SamAG7.5KSSum4
63/4/2022250400TimEZ6OK
75/1/2022600705JohnI8TX
Sheet2
Cell Formulas
RangeFormula
L5L5=SUMPRODUCT(INDEX($A$2:$I$99,,MATCH("Units",$A$1:$I$1,0)),(INDEX($A$2:$I$99,,MATCH("Product",$A$1:$I$1,0))=$L$3)*(INDEX($A$2:$I$99,,MATCH("State",$A$1:$I$1,0))=$L$4)*(INDEX($A$2:$I$99,,MATCH("Id 1",$A$1:$I$1,0))<=$L$2)*(INDEX($A$2:$I$99,,MATCH("Id 2",$A$1:$I$1,0))>=$L$2) )
 
Upvote 0
Solution
Try this...
MrExcel_20220803.xlsx
ABCDEFGHIJKL
1DateId 1Id 2NameProductUnitsStateFilters
21/1/2022100200SamAG2.5KSID375
33/4/2021600700TimEZ1.3OKProductI
45/6/2021350400JohnI4TXStateTX
51/7/2021500700SamAG7.5KSSum4
63/4/2022250400TimEZ6OK
75/1/2022600705JohnI8TX
Sheet2
Cell Formulas
RangeFormula
L5L5=SUMPRODUCT(INDEX($A$2:$I$99,,MATCH("Units",$A$1:$I$1,0)),(INDEX($A$2:$I$99,,MATCH("Product",$A$1:$I$1,0))=$L$3)*(INDEX($A$2:$I$99,,MATCH("State",$A$1:$I$1,0))=$L$4)*(INDEX($A$2:$I$99,,MATCH("Id 1",$A$1:$I$1,0))<=$L$2)*(INDEX($A$2:$I$99,,MATCH("Id 2",$A$1:$I$1,0))>=$L$2) )
Worked perfectly, no errors!! Thanksamillion!!! I apologize for the confusion and thank you for your time and patience, greatly appreciated!!
 
Upvote 0
Sorry...I missed the point about not knowing a specific range. Here is an idea that requires you to specify a large range where the columns will be found...and then using INDEX/MATCH to return each column of interest, wherever they might be in that range. But I still don't understand the Id1 and Id2 point. The formula below requires Id1=350 and Id2=400. What does Id1 and Id2 mean? Are those the upper and lower limits for Id's to be considered, so that someone with an Id of 375 would be included? Where are the Id numbers associated with each "Name" found?
MrExcel_20220803.xlsx
ABCDEFGHIJKL
1DateId 1Id 2NameProductUnitsStateID lower350
21/1/2022100200SamAG2.5KSID upper400
33/4/2021600700TimEZ1.3OKProductI
45/6/2021350400JohnI4TXStateTX
51/7/2021500700SamAG7.5KSSum4
63/4/2022250400TimEZ6OK
75/1/2022600705JohnI8TX
Sheet2
Cell Formulas
RangeFormula
L5L5=SUMPRODUCT(INDEX($A$2:$I$99,,MATCH("Units",$A$1:$I$1,0)),(INDEX($A$2:$I$99,,MATCH("Product",$A$1:$I$1,0))=$L$3)*(INDEX($A$2:$I$99,,MATCH("State",$A$1:$I$1,0))=$L$4)*(INDEX($A$2:$I$99,,MATCH("Id 1",$A$1:$I$1,0))=$L$1)*(INDEX($A$2:$I$99,,MATCH("Id 2",$A$1:$I$1,0))=$L$2) )
Good Morning,
I forgot to mention, "Product" (Column E) may have more than one possibility of product (Ex. I, I+, or I-) and will need to sum all possibilities at times, so I tried to use a wildcard and it is not working with the formula, please help! ,,MATCH("Product",$A$1:$I$1,0))=$L$3&"*")* and this one ,,MATCH("Product",$A$1:$I$1,0))="*"&$L$3&"*")*
 
Upvote 0

Forum statistics

Threads
1,215,487
Messages
6,125,079
Members
449,205
Latest member
Healthydogs

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