Problem with value for VLOOKUP.

BillP

Board Regular
Joined
May 16, 2007
Messages
63
Office Version
  1. 365
  2. 2007
Platform
  1. Windows
Good afternoon!

I'm trying to make a worksheet as simple as possible for another user.

I'm using VLOOKUP to get a county FIPS code based on a Zip Code. Normally, that's fine. But the lists the person has to work with have 9-digit Zip Codes (xxxxx-xxxx), and I need to pull out only the first 5 digits.

If I use the LEFT function in a helper column, I can see the 5-digit result, but VLOOKUP can't, and it gives a #VALUE error. I can't use the LEFT function inside a VLOOKUP forrmula. I don't want them to have to copy-and-paste-special-text each time.

What can I do to get a lookup based on only the first 5 digits that are automatically extracted?

Thanks for your help.
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
What version of Excel are you using? If you have O365, you can use the xlookup.

Book1.xlsm
JKLMNO
16ziphelperfips204505555
1790010-215900104444
1820450-012204505555
1929281-145292816666
Sheet3
Cell Formulas
RangeFormula
O16O16=XLOOKUP(N16,K17:K19,L17:L19)
K17:K19K17=NUMBERVALUE(LEFT(J17,5))
 
Upvote 0
What version of Excel are you using?

I suggest that you update your Account details (or 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’)

You can use left inside vlookup like
Excel Formula:
=VLOOKUP(LEFT(A2,5)+0,Sheet1!a2:b100,2,0)
 
Upvote 0
Solution
A few examples posted with the forum's tool named XL2BB would be useful.

T202212a.xlsm
ABCDEF
1CodeCountry
255555-4444CC12345A
312345-1234AA34567B
434567-2111BB55555C
5
4a
Cell Formulas
RangeFormula
B2:B4B2=VLOOKUP(--LEFT(A2,5),$E$2:$F$5,2,0)
C2:C4C2=XLOOKUP(--LEFT(A2,5),$E$2:$E$4,$F$2:$F$4,,0)


T202212a.xlsm
ABCDEF
6CodeCountry
755555-444455555CC12345A
812345-123412345AA34567B
934567-211134567BB55555C
10
4a
Cell Formulas
RangeFormula
B7:B9B7=--LEFT(A7,5)
C7:C9C7=VLOOKUP(B7,$E$2:$F$5,2,0)
D7:D9D7=XLOOKUP(B7,$E$2:$E$4,$F$2:$F$4,,0)
 
Last edited:
Upvote 0
Thank you!
I'm sorry I forgot to mention that I'm using Excel 365. I haven't been here in years.
I like the one-step solution from Fluff (I didn't know about the +0; I had everything else right).
But I also liked Cancyman8019's suggestion. I've never used NUMBERVALUE.
Nor have I used Dave Patton's -- .

You learn something every day, if you're not careful.
 
Upvote 0
The +0 or double negative -- coerce the text information to a number. You can use either.
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,224,800
Messages
6,181,044
Members
453,014
Latest member
Chris258

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