VLOOKUP mult. values and sum result?

BradMichaels

New Member
Joined
May 19, 2011
Messages
8
I have a question on the VLOOKUP function.

I have a spreadsheet that lists out clients with their account numbers and the revenue they earn (B2:D7). I have a data range (F2:G22) that lists revenue by account number. Some clients have multiple accounts and I'd like the vlookup result to show the sum of the revenue for the multiple accounts. If possible, how would I structure that formula?

excel_ex.jpg
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
You could do something like this, but it would change depending on how many accts you are looking up.

=vlookup(left(c3,4),f2:g22,2,0)+vlookup(mid(c3,6,4),f2:g22,2,0)+ ect...
 
Upvote 0
Are the account numbers all four digits in length, as per your example? If so, try...

D3, confirmed with CONTROL+SHIFT+ENTER, and copied down:

=SUM(IF(ISNUMBER(MATCH($F$2:$F$22,MID(SUBSTITUTE(C3," ",""),ROW(INDIRECT("1:"&LEN(C3)-LEN(SUBSTITUTE(C3,",",""))+1))*5-5+1,4)+0,0)),$G$2:$G$22))

or

D3, confirmed just with ENTER, and copied down:

=SUMPRODUCT(SUMIF($F$2:$F$22,MID(SUBSTITUTE(C3," ",""),ROW(INDIRECT("1:"&LEN(C3)-LEN(SUBSTITUTE(C3,",",""))+1))*5-5+1,4),$G$2:$G$22))
 
Upvote 0
You could do something like this, but it would change depending on how many accts you are looking up.

=vlookup(left(c3,4),f2:g22,2,0)+vlookup(mid(c3,6,4),f2:g22,2,0)+ ect...

Thanks, a few additional questions on your answer:

In the formula you provided, for the second vlookup formula, is the purpose of '(C3,6,4)' saying in cell C3 starting at character 6 use next 4 characters to match?

Continuing with your pattern (left, mid, etc) what would the last one be right? What if I had 4 account numbers?
 
Upvote 0
Are the account numbers all four digits in length, as per your example? If so, try..

Used the second formula you provided and it worked perfectly. I wish I could understand how it works though. What would have to change if I switched my account number to a different length?
 
Upvote 0
Have you tried the formulas? If so, do they return the desired result?


Yes they both work.

What would I have to change if I switched my account number to a different length? Sorry, I don't fully understand the functions of the formula to figure it out myself.
 
Upvote 0
I have a question on the VLOOKUP function.

I have a spreadsheet that lists out clients with their account numbers and the revenue they earn (B2:D7). I have a data range (F2:G22) that lists revenue by account number. Some clients have multiple accounts and I'd like the vlookup result to show the sum of the revenue for the multiple accounts. If possible, how would I structure that formula?

excel_ex.jpg
This would be so much easier if you put each acct number in its own cell:

Book1
ABCDE
1RevenueClientAcct(s)__
2500A10011004_
3200B1002__
41200C100310041005
Sheet1

Book1
GH
1AcctRevenue
21001100
31002200
41003300
51004400
61005500
Sheet1

Then, the formula entered in cell A2 and copied down:

=SUMPRODUCT(SUMIF(G$2:G$6,C2:E2,H$2:H$6))
 
Upvote 0
This would be so much easier if you put each acct number in its own cell:

I agree, but that's not going to happen although I'm making a case for it. The example I provided was just to explain what I'm trying to figure out how to do as I do multiple account summations manually today.
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,848
Members
452,948
Latest member
UsmanAli786

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