vlookup a table with a value before a comma

Dares2

New Member
Joined
Feb 27, 2017
Messages
24
hi, I have a need to vlookup a surname in a list but the lookup range has both surname, comma then first name so eg vlookup(smith in a list that has smith,david and take the forth value along) Im not sure how to write this formula thanks.
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
63,925
Office Version
  1. 365
Platform
  1. Windows
You can do that like
Excel Formula:
=VLOOKUP(X2&"*",A2:D100,4,0)
where X2 is the cell with the value to find.
 

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
51,142
Office Version
  1. 365
Platform
  1. Windows
I would suggest including the comma in the lookup value (Y2 formula) to avoid a possible incorrect result (Z2 formula)

21 05 03.xlsm
ABCDEWXYZ
1post #3post #2
2jones, alan147smith98
3smithson, anne258
4smith, david369
VLOOKUP
Cell Formulas
RangeFormula
Y2Y2=VLOOKUP(X2&",*",A2:D100,4,0)
Z2Z2=VLOOKUP(X2&"*",A2:D100,4,0)
 

Dares2

New Member
Joined
Feb 27, 2017
Messages
24
I would suggest including the comma in the lookup value (Y2 formula) to avoid a possible incorrect result (Z2 formula)

21 05 03.xlsm
ABCDEWXYZ
1post #3post #2
2jones, alan147smith98
3smithson, anne258
4smith, david369
VLOOKUP
Cell Formulas
RangeFormula
Y2Y2=VLOOKUP(X2&",*",A2:D100,4,0)
Z2Z2=VLOOKUP(X2&"*",A2:D100,4,0)
Thanks although I couldnt get this to work. May because this is the otherway round ie looking up eg smith within a lookup range of smith,peter

NameGross pf
new
FnightsTotal
Baker, Annie$1,000.004.00=SUM(C5*D5)+VLOOKUP(A5&"*",C9:E11,2,FALSE)
BakerBlue2237
BawdenRed2273
SmithGreen2283
 

Dares2

New Member
Joined
Feb 27, 2017
Messages
24

ADVERTISEMENT

You can do that like
Excel Formula:
=VLOOKUP(X2&"*",A2:D100,4,0)
where X2 is the cell with the value to find.
Not sure but couldnt get this to work

NameGross pf
new
FnightsTotal
Baker, Annie$1,000.004.00=SUM(C5*D5)+VLOOKUP(A5&"*",C9:E11,2,FALSE)
BakerBlue2237
BawdenRed2273
SmithGreen2283
 

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
51,142
Office Version
  1. 365
Platform
  1. Windows
May because this is the otherway round
Yes, it appears that you described this the wrong way around in your original post. But it also looks like you have the wrong column referenced in the lookup range in your latest attempt.
Is below what you want?

BTW, I suggest that you
  • Update your Account details (click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
  • Investigate XL2BB for providing sample data to make it easier for helpers.

21 05 03.xlsm
ABCDE
4NameGross pf newFnightsTotal
5Baker, Annie$1,000.004$6,237.00
6
7
8
9BakerBlue2237
10BawdenRed2273
11SmithGreen2283
VLOOKUP (2)
Cell Formulas
RangeFormula
E5E5=C5*D5+VLOOKUP(LEFT(A5,FIND(",",A5)-1),C9:E11,3,FALSE)
 

Dares2

New Member
Joined
Feb 27, 2017
Messages
24
Yes, it appears that you described this the wrong way around in your original post. But it also looks like you have the wrong column referenced in the lookup range in your latest attempt.
Is below what you want?

BTW, I suggest that you
  • Update your Account details (click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
  • Investigate XL2BB for providing sample data to make it easier for helpers.

21 05 03.xlsm
ABCDE
4NameGross pf newFnightsTotal
5Baker, Annie$1,000.004$6,237.00
6
7
8
9BakerBlue2237
10BawdenRed2273
11SmithGreen2283
VLOOKUP (2)
Cell Formulas
RangeFormula
E5E5=C5*D5+VLOOKUP(LEFT(A5,FIND(",",A5)-1),C9:E11,3,FALSE)
thanks so much..worked a treat
 

Forum statistics

Threads
1,144,243
Messages
5,723,207
Members
422,485
Latest member
Tameima

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
Top