Cut length of Vlookup results

Factotum

Board Regular
Joined
May 14, 2015
Messages
118
Would anyone know how to return only the first several digits of a vlookup value? I'm trying to save space by shrinking the columns and only having a portion of the lookup value.

For example, my source data shows the table below. I would like to just pull in "Jones, Indiana". I've tried variations of LEN and TRIM nested with the VLOOKUP, but can't seem to get it right. Thanks for any ideas!

[TABLE="class: grid, width: 500, align: left"]
<tbody>[TR]
[TD]Employee ID[/TD]
[TD]Employee Name[/TD]
[/TR]
[TR]
[TD]123456[/TD]
[TD]Jones, Indiana Junior the Fourth Esquire[/TD]
[/TR]
</tbody>[/TABLE]
 

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)
Not sure if they are all formatted the same. But this would give you everything before the 2nd space.

Code:
=LEFT(B2,FIND(" ", B2, FIND(" ", B2)+1))

With some testing it appears to give me the correct result. However, every B2 would need to be your vlookup.

Or you could Vlookup into B, use the above formula in C, and hide B.
 
Upvote 0
Or if you only want say the 1st 10 or 15 characters of your vlookup results, just surround the vlookup with the LEFT function, like this:

Code:
=left(vlookup(a1,a1:b10,2,0),15)

That would do whatever your vlookup is and then trim it down to only the 1st 15 characters that come back.
Obviously put in your vlookup in place of my code there and change the 15 to whatever you want it to be.
 
Upvote 0
If you want to just return the first X number of characters then this will work. Change the 15 to the number of
Code:
=TRIM(LEFT(VLOOKUP(A9,A2:B3,2,0),15))
 
Upvote 0
Thank you philwojo!

That was such a painfully obvious solution, I'm embarrassed that I posted it!:oops: I'm always using =vlookup(left....) but I never thought to use =left(vlookup...). Thank you so much for your help!
 
Last edited:
Upvote 0
Oh I'd assumed that wasn't working because of varying lengths of different names and needed something more intricate. Glad you got it figured out though
 
Upvote 0
If it will always be in that format last name, first name (space after first name) then this will pull just the last and first name regardless of length


Excel 2010
AB
1Employee IDEmployee Name
2123456Jones, Indiana Junior the Fourth Esquire
313498799Green, Beth the farmer
47Loooooooooongname, firsttttttsname the thrid
5
6
7
8
9123456Jones, Indiana
107Loooooooooongname, firsttttttsname
1113498799Green, Beth
iRFQ
Cell Formulas
RangeFormula
B9=TRIM(LEFT(VLOOKUP(A9,A2:B4,2,0),SEARCH(" ",VLOOKUP(A9,A2:B4,2,0),SEARCH(",",VLOOKUP(A9,A2:B4,2,0))+2)))
B10=TRIM(LEFT(VLOOKUP(A10,A2:B4,2,0),SEARCH(" ",VLOOKUP(A10,A2:B4,2,0),SEARCH(",",VLOOKUP(A10,A2:B4,2,0))+2)))
B11=TRIM(LEFT(VLOOKUP(A11,A2:B4,2,0),SEARCH(" ",VLOOKUP(A11,A2:B4,2,0),SEARCH(",",VLOOKUP(A11,A2:B4,2,0))+2)))
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,157
Members
453,021
Latest member
Justyna P

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