Sum up to 12 columns based on two criteria

MurrayBarn

New Member
Joined
May 27, 2012
Messages
32
Office Version
  1. 365
Platform
  1. Windows
Hi There

I have tried SUMIFS, using AND and SUMIF, SUMPRODUCT etc but can't find a tidy way to sum from 1 to 12 columns based on two criteria. Essentially what I have is a 12 months of Profit and Loss data in columns D:O. I then have the Account Code (criteria 1) in Column A and Department (criteria 2) in column B.

I have a Control sheet that I change the number from 1 to 12 on and I would like a formula that will sum columns D to whatever the control number is, based on criteria 1 and 2. So if I type in 3, it must sum D:F when it finds criteria 1 and criteria 2

I guess I could also use a multiple lookup as there is only one number per month, per account code and per department, but I am not sure how to do that.

Does anybody have a tidy solution?
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
With
Data tab:

A1: Acct
A2:A20 contains accounts

B1: Dept
B2:B20 contains departments

D1:O1 contains months: Jan, Feb,...Dec
D2:O20 contains amounts

Control tab:
B2: EndMonth...5
B5: Acct
B6: an acct to lookup

C5: Dept
C6: a dept to lookup

D5: YTD
This regular formula returns the sum for that combination for months 1 through the B2 value
Code:
D6: =SUM(OFFSET(Data!C1,MATCH(Control!B6&"_"&Control!C6,INDEX(Data!A2:A20&"_"&Data!B2:B20,0),0),1,1,B2))

Note: the OFFSET function is volatile, so it recalcs whenever any cell in the workbook recalcs. Consequently, if too many are used the workbook may become sluggish.

Is that something you can work with?
 
Upvote 0
Hi Ron - I have just tried your formula slightly modified. I no longer have a second column of criteria but i have up to four rows that contain the same lookup and it is only summing the first row.

I again have a profit and loss statement for 12 months. In column A is the account code and there can be up to 8 rows with the same account code in it as there are 8 divisions. If I delete the second criteria out of your formula, it correctly looksup and finds the account code, but only sums the first row it finds. Any ideas?
 
Upvote 0

Forum statistics

Threads
1,223,249
Messages
6,171,031
Members
452,374
Latest member
keccles

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