Vlookup with Partial Text Match

OkampoVictory

New Member
Joined
Jan 22, 2018
Messages
6
Hello Everyone,

I am hoping to populate a cell in a worksheet using Vlookup and a lookup value. The lookup value is a First and a Last Name (e.g. Serena Williams). The table array is on a separate worksheet containing the staff details for all the staff in this company. However, the first and last name are on two separate columns (e.g. B1: Williams C1:Serena). The Vlookup formula I entered was not working. I have attached the example below:

Worksheet 1:
[TABLE="width: 376"]
<colgroup><col span="2"></colgroup><tbody>[TR]
[TD][TABLE="width: 500"]
<tbody>[TR]
[TD]Staff
[/TD]
[TD]Rank
[/TD]
[/TR]
[TR]
[TD]Serena Williams
[/TD]
[TD](Want Result Here)
[/TD]
[/TR]
</tbody>[/TABLE]

Worksheet 2
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="width: 500"]
<tbody>[TR]
[TD]Surname
[/TD]
[TD]Forename
[/TD]
[TD]Position
[/TD]
[TD]Reporting Unit
[/TD]
[TD]Joining Date
[/TD]
[TD]Grade
[/TD]
[TD]Rank
[/TD]
[/TR]
[TR]
[TD]Williams
[/TD]
[TD]Serena
[/TD]
[TD]Manager
[/TD]
[TD]Finance
[/TD]
[TD]12/12/2012
[/TD]
[TD]B
[/TD]
[TD]Senior Manager
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

Ideally, the Vlookup formula will return the rank based on part of the name present in worksheet 1.

Many thanks for your help!

Victory
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Which part of the name? first name or surname?

You will get errors when only partially checking and the same first name or surname appear. dependant on how you want to search
 
Upvote 0
Hi, welcome to the board!

Here are a couple of options, the Option1 uses both the first name and the second, Option 2 just uses the first name.


Excel 2013/2016
ABC
1StaffOption 1Option 2
2Serena WilliamsSenior ManagerSenior Manager
3Tim HenmanTeam LeaderTeam Leader
Sheet1
Cell Formulas
RangeFormula
B2=INDEX(Sheet2!$G$2:$G$1000,MATCH(A2,INDEX(Sheet2!$B$2:$B$1000&" "&Sheet2!$A$2:$A$1000,0),0))
C2=VLOOKUP(LEFT(A2,FIND(" ",A2&" ")-1),Sheet2!$B$1:$G$1000,6,0)



Excel 2013/2016
ABCDEFG
1SurnameForenamePositionReporting UnitJoining DateGradeRank
2WilliamsSerenaManagerFinance12/12/2012BSenior Manager
3BeckerBorisTea BoyCatering01/01/2001AManager
4HenmanTimPlayerHR01/01/2001CTeam Leader
Sheet2
 
Last edited:
Upvote 0
this should do the trick

=VLOOKUP(LEFT(A2,SEARCH(" ",A2,1)-1),Sheet2!B2:G13,5,0)



​Explained
=VLOOKUP(LEFT(A2,SEARCH(" ",A2,1)-1),Sheet2!B2:G13,5,0)

This looks in A2 and finds the space character and takes one from that number, essentially how long the first name is

this extracts the first name determined by the length found in red

The rest of the formula simply is the Vlookup for the entire first name from your data range on sheet 2.
 
Upvote 0
Hello Everyone,

I am hoping to populate a cell in a worksheet using Vlookup and a lookup value. The lookup value is a First and a Last Name (e.g. Serena Williams). The table array is on a separate worksheet containing the staff details for all the staff in this company. However, the first and last name are on two separate columns (e.g. B1: Williams C1:Serena). The Vlookup formula I entered was not working. I have attached the example below:

Worksheet 1:
[TABLE="width: 376"]
<tbody>[TR]
[TD][TABLE="width: 500"]
<tbody>[TR]
[TD]Staff[/TD]
[TD]Rank[/TD]
[/TR]
[TR]
[TD]Serena Williams[/TD]
[TD](Want Result Here)[/TD]
[/TR]
</tbody>[/TABLE]

Worksheet 2[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="width: 500"]
<tbody>[TR]
[TD]Surname[/TD]
[TD]Forename[/TD]
[TD]Position[/TD]
[TD]Reporting Unit[/TD]
[TD]Joining Date[/TD]
[TD]Grade[/TD]
[TD]Rank[/TD]
[/TR]
[TR]
[TD]Williams[/TD]
[TD]Serena[/TD]
[TD]Manager[/TD]
[TD]Finance[/TD]
[TD]12/12/2012[/TD]
[TD]B[/TD]
[TD]Senior Manager[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

Ideally, the Vlookup formula will return the rank based on part of the name present in worksheet 1.

Many thanks for your help!

Victory

Assuming U have 5 rows of names, this will be the formula:

=INDEX(Worksheet2!G$2:G$5,MATCH(1,(LEFT(A2,(FIND(" ",A2)-1))=Worksheet2!B$2:B$6)*(MID(A2,FIND(" ",A2)+1,256)=Worksheet2!A$2:A$6),0))
 
Last edited:
Upvote 0
Hi Simon4s,

Unfortunately I am a bit of a novice still with Excel but your solution gives me something to learn and understand. Thanks for your help!
Victory
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,996
Members
452,373
Latest member
TimReeks

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