Is Sumif the right formula to use here?

Tigerexcel

Active Member
Joined
Mar 6, 2020
Messages
493
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
I would like a conditional column total depending on which month is randomly selected:

JanFebMarFeb
151
852Total for5
944
753
116

In this case if cell F1 reads Feb, the total should be 20 but i get 5, my formula is only picking up the first cell. The formula I have is =SUMIF(A1:C1,F1,A2:C6). Can this Sumif formula be adjusted to work here, or is there a better option?
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
MrExcel.xlsx
ABCDEF
1JanFebMarFeb
2151
3852Total for20
4944
5753
6116
7
Sheet5
Cell Formulas
RangeFormula
F3F3=SUM(OFFSET(A2:A6,,MATCH(F1,A1:C1,)-1))

MrExcel.xlsx
ABCDEF
1JanFebMarMar
2151
3852Total for16
4944
5753
6116
Sheet5
Cell Formulas
RangeFormula
F3F3=SUM(OFFSET(A2:A6,,MATCH(F1,A1:C1,)-1))
 
Upvote 0
How about
=SUMPRODUCT((A1:C1=F1)*(A2:C6))
or
=SUM(INDEX(A2:C6,,MATCH(F1,A1:C1,0)))
 
Upvote 0
SUM function:
MrExcel.xlsx
ABCDEF
1JanFebMarMar
2151
3852Total for16
4944
5753
6116
Sheet5
Cell Formulas
RangeFormula
F3F3=SUM(A2:C6*(A1:C1=F1))
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Thanks Shaowu and Fluff. The last 3 formulae work, the offset formula calculates all months rather than the specific month required.

I can see now that SUMIF was the incorrect choice here. If I wanted to make the calculation more dynamic (as rows and extra columns will be added at a later time), which of these functions would be easiest to alter to allow for this?
 
Upvote 0
Thanks Shaowu and Fluff. The last 3 formulae work, the offset formula calculates all months rather than the specific month required.

I can see now that SUMIF was the incorrect choice here. If I wanted to make the calculation more dynamic (as rows and extra columns will be added at a later time), which of these functions would be easiest to alter to allow for this?
The offset formula seems OK for me, have you copied the formula in my post?
 
Upvote 0
Thanks Shaowu and Fluff. The last 3 formulae work, the offset formula calculates all months rather than the specific month required.

I can see now that SUMIF was the incorrect choice here. If I wanted to make the calculation more dynamic (as rows and extra columns will be added at a later time), which of these functions would be easiest to alter to allow for this?
All the above formulas will be easily modified to suit expanded ranges.
 
Upvote 0
MrExcel.xlsx
ABCDEF
1JanFebMarFeb
2151
3852Total for20
4944
5753
6116
7
Sheet5
Cell Formulas
RangeFormula
F3F3=SUM(OFFSET(A2:A6,,MATCH(F1,A1:C1,)-1))

MrExcel.xlsx
ABCDEF
1JanFebMarMar
2151
3852Total for16
4944
5753
6116
Sheet5
Cell Formulas
RangeFormula
F3F3=SUM(OFFSET(A2:A6,,MATCH(F1,A1:C1,)-1))
In this post i showed two cases, seems get the right result.
 
Upvote 0
Apologies Shaowu, I used a named range in your offset formula and that picked up the other months. Your formula works fine.
All the above formulas will be easily modified to suit expanded ranges.
Just to clarify, I was after a dynamic update rather than manually altering the formula.
 
Upvote 0
Best way to make it dynamic is to turn the data into a structured table

+Fluff New.xlsm
ABCDEFG
1JanFebMarAprapr
21511
38522Total for28
49443
57534
61165
72346
85677
9
Data
Cell Formulas
RangeFormula
G3G3=SUM(INDEX(Table1,,MATCH(G1,Table1[#Headers],0)))
 
Upvote 0

Forum statistics

Threads
1,215,013
Messages
6,122,690
Members
449,092
Latest member
snoom82

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