VLOOKUP Approximate Match Issue

LVExcel

Board Regular
Joined
Nov 23, 2011
Messages
59
Office Version
  1. 365
Platform
  1. Windows
I need help with using VLOOKUP approximate match (Excel 2010).

My formula result is either #N/A or the previous row is being returned; in some instances the correct zone is returned.
My desired result is to lookup a ZipCode (example: 13015, only first 3 digits matter), and return the Zone for the corresponding shipping Service (Ground or NextDay). For "10040" it should return the zone in cell B8.

I'm trying to avoid having to break out the list, for example: "004-005" equals, 00401, 00402, 00403 ... to 00599. It's a long list.


A B C D E F
1Dest. ZIPGroundNext Day ZipCode Formula
2004-00500610610040 =VLOOKUP(LEFT(E2,3),A:C,2,TRUE)
3006-00704512511368
400904512520004
5010-04600610613005
604700710717796
7048-089006106
8100-129006106
9130-132005105
10133-139006106
11140-174005105
12175-176006106
13177-178005105
14179-199006106
15200-205005105
16206-208006106
17209-213005105

<tbody>
</tbody>

To see data I'm dealing with, you can quickly download the list at:

UPS: Zones and Rates for the 48 Contiguous States
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
I think you may need to add in another column like this:

Short ZipDest. ZIPGroundNext DayZipCodeFormula
004004-0056106100406
006006-00745125113686
00900945125200045
010010-0466106130055
0470477107177965
048048-0896106
100100-1296106
130130-1325105
133133-1396106
140140-1745105
175175-1766106
177177-1785105
179179-1996106
200200-2055105
206206-2086106
209209-2135105
=left(C19,3)

<colgroup><col><col><col><col><col span="2"><col></colgroup><tbody>
</tbody>
 
Upvote 0
I think you may need to add in another column like this:

Short ZipDest. ZIPGroundNext DayZipCodeFormula
004004-0056106100406
006006-00745125113686
00900945125200045
010010-0466106130055
0470477107177965
048048-0896106
100100-1296106
130130-1325105
133133-1396106
140140-1745105
175175-1766106
177177-1785105
179179-1996106
200200-2055105
206206-2086106
209209-2135105
=left(C19,3)

<tbody>
</tbody>

then get it to look up the short zip rather than the full one ..
 
Upvote 0
Perhaps

=VLOOKUP(LEFT(E2,3)&"*",A:C,2,FALSE)

Hey, that worked!!! Can you share the logic behind this. Why is this needed when I'm only looking at the first 3 left digits.
 
Upvote 0
The "approximate match" function of vlookup is really intended for use on Numerical Ranges.
1
10
20
30
=VLOOKUP(12,A:B,1,TRUE) = 10

It doesn't work very well with TEXT data, and you get very strange results. As you've seen.
When dealing with TEXT, exact match is really best.


Now the Exact Match does allow wildcards, that's what the &"*" does
If E2 = 10040 then LEFT(E2,3)&"*" = 100*
The * is the wildcard, so it only looks at the first 3 characters in Column A.
 
Upvote 0
Perhaps

=VLOOKUP(LEFT(E2,3)&"*",A:C,2,FALSE)

Unfortunately this will not work in every instance. The formula with FALSE is looking for an exact match of the first 3 digits on the LEFT regardless of what follows; however, what these numbers represent are ranges of Zip Codes. For example: "004-005" equals, 00401, 00402, 00403 ... to 00599. When looking for "005" I get #N/A since those are not the LEFT most 3 digits.

Hodpy62's suggestion will work, however, other users will be using this file and have no idea how to enter formulas;
I prefer to use a formula that I can keep hidden.

Any ideas? I like the direction Jonmo1 is taking, but its not there yet.
 
Upvote 0
I'm confused...

You said.
My desired result is to lookup a ZipCode (example: 13015, only first 3 digits matter), and return the Zone for the corresponding shipping Service (Ground or NextDay). For "10040" it should return the zone in cell B8.

Now you DO want to look at the right digits....
 
Upvote 0

Forum statistics

Threads
1,215,151
Messages
6,123,321
Members
449,094
Latest member
Chestertim

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