HLOOKUP multiple values with SUMPRODUCT?

megera716

Board Regular
Joined
Jan 3, 2013
Messages
139
Office Version
  1. 365
Platform
  1. Windows
I have a huge export out of data out of our accounting system that lists all our departments down one side and all P&L account names across the top. I update my reporting monthly and sometimes the P&L account name shifts one or multiple columns as expenses in more accounts are introduced throughout the year. (E.g., at the beginning of the year, we might just have payroll, but by the end we have payroll, health insurance, travel, contractors, etc. etc. etc.). I copied and pasted a bunch of random amounts from other sources so you'd get the idea :P.

What I want in the Total Employee Expenses column at the end is the sum of all the values on that row from the Health Insurance, Employee Benefits or Payroll Expenses columns (the accounts in the first row). I can't just do a straight SUM across because I update this monthly and the order of the P&L accounts shifts around on the export from the accounting system and as you can see there is Rent and Travel interspersed. Hopefully this makes sense!!


I found this =SUM(VLOOKUP(A10, $A$2:$F$7, {2,3,4,5,6}, FALSE)) in my internet search but that would work if my values were in multiple columns, but mine are in multiple rows and I think I need the SUMPRODUCT because I don't always want to return just the first value it finds. I don't know if I'm making any sense ?

Health InsuranceRentEmployee BenefitsPayroll ExpensesHealth InsuranceEmployee BenefitsPayroll ExpensesTravelEmployee BenefitsHealth InsuranceTravelPayroll Expenses
(Administrative)(Administrative)(Administrative)(Administrative)(Sales)(Sales)(Sales)(Sales)(Product)(Product)(Product)(Product)Total Employee Expenses
Department1
84,259​
36,032​
104,903​
94,705​
74,294​
83,784​
0​
85,628​
Department2
23,368​
84,622​
80,052​
81,968​
155​
13,683​
Department3
18,507​
103,995​
105,373​
116,313​
5,587​
10,636​
Department4
84,259​
13,192​
104,903​
94,705​
25,814​
74,294​
83,784​
0​
85,628​
Department5
47,142​
84,622​
80,052​
81,968​
10,374​
0​
Department6
11,229​
103,995​
105,373​
116,313​
0​
1,548​
Department7
84,259​
7,534​
104,903​
94,705​
21,365​
74,294​
83,784​
0​
85,628​
Department8
5,089​
84,622​
80,052​
81,968​
0​
0​
Department9
6,460​
103,995​
105,373​
116,313​
0​
7,232​
Department10
84,259​
5,614​
104,903​
94,705​
0​
74,294​
83,784​
0​
85,628​
0​
 

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.
Try:
Book1
ABCDEFGHIJKLMN
1Health InsuranceRentEmployee BenefitsPayroll ExpensesHealth InsuranceEmployee BenefitsPayroll ExpensesTravelEmployee BenefitsHealth InsuranceTravelPayroll Expenses
2(Administrative)(Administrative)(Administrative)(Administrative)(Sales)(Sales)(Sales)(Sales)(Product)(Product)(Product)(Product)Total Employee Expenses
3Department18425930032104903947057429483784085628527573
4Department22336884622800528196815513683283848
Sheet1
Cell Formulas
RangeFormula
N3:N4N3=SUM(FILTER(B3:M3,($B$1:$M$1="Health Insurance")+($B$1:$M$1="Employee Benefits")+($B$1:$M$1="Payroll Expenses")))
 
Upvote 0
Try:
Book1
ABCDEFGHIJKLMN
1Health InsuranceRentEmployee BenefitsPayroll ExpensesHealth InsuranceEmployee BenefitsPayroll ExpensesTravelEmployee BenefitsHealth InsuranceTravelPayroll Expenses
2(Administrative)(Administrative)(Administrative)(Administrative)(Sales)(Sales)(Sales)(Sales)(Product)(Product)(Product)(Product)Total Employee Expenses
3Department18425930032104903947057429483784085628527573
4Department22336884622800528196815513683283848
Sheet1
Cell Formulas
RangeFormula
N3:N4N3=SUM(FILTER(B3:M3,($B$1:$M$1="Health Insurance")+($B$1:$M$1="Employee Benefits")+($B$1:$M$1="Payroll Expenses")))

Thank you! I am not even familiar with FILTER as a function! I’ll give this a try in the morning :)
 
Upvote 0
Another option, if you haven't got the Filter function yet.
+Fluff New.xlsm
ABCDEFGHIJKLMN
1Health InsuranceRentEmployee BenefitsPayroll ExpensesHealth InsuranceEmployee BenefitsPayroll ExpensesTravelEmployee BenefitsHealth InsuranceTravelPayroll Expenses
2(Administrative)(Administrative)(Administrative)(Administrative)(Sales)(Sales)(Sales)(Sales)(Product)(Product)(Product)(Product)Total Employee Expenses
3Department184,25936,032104,90394,70574,29483,784085,628527573
4Department223,36884,62280,05281,96815513,683283848
5Department318,507103,995105,373116,3135,58710,636360411
6Department484,25913,192104,90394,70525,81474,29483,784085,628527573
7Department547,14284,62280,05281,96810,3740304158
8Department611,229103,995105,373116,31301,548338458
9Department784,2597,534104,90394,70521,36574,29483,784085,628527573
10Department85,08984,62280,05281,96800251731
11Department96,460103,995105,373116,31307,232339373
12Department1084,2595,614104,90394,705074,29483,784085,628527573
Main
Cell Formulas
RangeFormula
N3:N12N3=SUM(SUMIFS(B3:M3,$B$1:$M$1,{"Health Insurance","Employee Benefits","Payroll Expenses"}))
 
Upvote 0
FILTER is a new function in Excel 365.

I ended up not getting to this yesterday but I tried it just now and it works beautifully!

@Fluff, I also tried yours which worked fine as well as you wrote it but it did not like me when I tried to add a cell reference as another criteria. I also tried using Ctrl-Shift-Enter, noting the curly brackets.

However, thank you both for your help! I love this forum! :)
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0
You're welcome. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,630
Messages
6,120,634
Members
448,973
Latest member
ChristineC

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