Sumif with dynamic range

AaronO

New Member
Joined
May 24, 2018
Messages
1
Hello,

I am struggling with a formula to create a sumif with a dynamic range.

The data I have is as follows:

ROW/COLUMNABCDEFGHIJKLMN
1DepartmentExpenseJan-18Feb-18Mar-18Apr-18May-18Jun-18Jul-18Aug-18Sep-18Oct-18Nov-18Dec-18
2FinancePhone199901074750112521908911110
3OperationsRecruitment11216120142861941911317816217027
4FinanceIT set up187131161618660155931701614394
5Managementetc133551518357741515736966986
6Adminetc8723626124701771593853101123
7Operationsetc511605672318215359789543

<tbody>
</tbody>

What I am after is to be able to type a month in a cell (say in cell Summary!A2) and a department in a cell (say Summary!A3), and then have two formulas. One summing up the numbers in the relative month column whereby the row matches to my department input. And one that provides a YTD amount for the department.

For example, if I typed Apr-18 and Finance into the two specified cells, I would want the first formula to sum up F2 & F4, and the second formula to sum up C2:F2 & C4:F4.

I have tried using Offsets and Match but just cannot get my formulae to work.

Will appreciate any help that can be provided.

Thank you,

Aaron
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Here are the formulas I came up with. You will have to add sheet names as you did not make it clear which sheet the formulas are going to be in and what the sheet name is where the data is located.

Formula 1:
=SUMPRODUCT((TEXT(C1:N1,"mmmm")=A11)*(A2:A7=A12)*C2:N7)

C1:N1 = Date Headers
A2:A7 = Departments
C2:N7 = Values
A11 and A12 would be your Summary!A2 and Summary!A3

Formula 2:
=SUMPRODUCT((MONTH(C1:N1)<=MONTH(DATEVALUE(A11&"1")))*(A2:A7=A12)*C2:N7)

C1:N1 = Date Headers
A2:A7 = Departments
C2:N7 = Values
A11 and A12 would be your Summary!A2 and Summary!A3
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,397
Members
448,957
Latest member
Hat4Life

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