VLOOKUP and Zipcodes with ZEROS

Utradeshow

Well-known Member
Joined
Apr 26, 2004
Messages
800
Office Version
  1. 365
Hi all,

I am Using a zip program to find nearest zip code. Then I use a VLOOKUP to populate cells. I have to convert the result of the zip code program to work with the VLOOKUP. I tried using VALUE function which works on zips with the full 5 digits and doesn't work with the ZERO leading Zipcodes. Then the TEXT function works with the "ZERO" zips and not the regular zip codes???? Any Suggestions?
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Copy of Rad One Delivery List with Agent (TEST2).xlsm
GHIJKL
6194460700417552700461#N/A
71944607004175521944618Hughes Relocation
1000 locations
Cell Formulas
RangeFormula
G6:G7G6=CDXClosestZip(E6,0,'Preferred Agents'!A$2:A$107)
H6:H7H6=CDXClosestZip(E6,4,'Preferred Agents'!A$2:A$107)
I6:I7I6=CDXClosestZip(E6,8,'Preferred Agents'!A$2:A$107)
J6J6=VALUE(TRIM(H6))
K6:K7K6=CDXDistance(E6,J6)
L6L6=VLOOKUP(J6,'Preferred Agents'!A:C,3,FALSE)
J7J7=VALUE(TRIM(G7))
L7L7=IFERROR(VLOOKUP(J7,'Preferred Agents'!A:C,3,FALSE),"")
 
Upvote 0
VLOOKUP requires that the values you match on be the same data type (you can compare "Text to Text" or "Numbers to Numbers", but never "Numbers to Text").
So "Numbers entered as Text" will be problematic if trying to compare to real "Numbers".

Changing the entries to numbers (values) will drop the leading zeroes.
Make/keep everything text, and it should keep leading zeroes, and everything should work.
 
Upvote 0
Copy of Rad One Delivery List with Agent (TEST2).xlsm
GHIJKL
6194460700417552700461#N/A
71944607004175521944618Hughes Relocation
1000 locations
Cell Formulas
RangeFormula
G6:G7G6=CDXClosestZip(E6,0,'Preferred Agents'!A$2:A$107)
H6:H7H6=CDXClosestZip(E6,4,'Preferred Agents'!A$2:A$107)
I6:I7I6=CDXClosestZip(E6,8,'Preferred Agents'!A$2:A$107)
J6J6=VALUE(TRIM(H6))
K6:K7K6=CDXDistance(E6,J6)
L6L6=VLOOKUP(J6,'Preferred Agents'!A:C,3,FALSE)
J7J7=VALUE(TRIM(G7))
L7L7=IFERROR(VLOOKUP(J7,'Preferred Agents'!A:C,3,FALSE),"")
Column J appears to be your problem, where you are converting the entries to numbers.

Can you show us some data from column A of your "Preferred Agents" sheet?
Be sure to show some Zip Codes that start with 0, and others that don't.
 
Upvote 0
Copy of Rad One Delivery List with Agent (TEST2).xlsm
GHIJKL
61944607004175520700461TTI Fairfield
71944607004175521944618#N/A
1000 locations
Cell Formulas
RangeFormula
G6:G7G6=CDXClosestZip(E6,0,'Preferred Agents'!A$2:A$107)
H6:H7H6=CDXClosestZip(E6,4,'Preferred Agents'!A$2:A$107)
I6:I7I6=CDXClosestZip(E6,8,'Preferred Agents'!A$2:A$107)
J6J6=TEXT(H6,"00000")
K6:K7K6=CDXDistance(E6,J6)
L6:L7L6=VLOOKUP(J6,'Preferred Agents'!A:C,3,FALSE)
J7J7=TEXT(G7,"00000")
 
Upvote 0
Copy of Rad One Delivery List with Agent (TEST2).xlsm
AB
3248507DTW
3379925ELP
3407004EWR
3549548GRR
Preferred Agents


From the Preferred Agent sheet
 
Upvote 0
Are your values in column A numbers with a Custom Zip code format, or are they entered as Text?

If you are unsure, there are a few days to tell.
1. Go to cell A34, and look at the number format on the cell (right-click on cell, go to Format Cells, go to the Number tab, see what option is selected). What is it?
2. Enter these formulas in any blank cells and tell us what they return:
Excel Formula:
=ISNUMBER(A34)
=ISNUMBER(A35)
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,774
Members
452,353
Latest member
strainu

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