Incorrect value picked up in Vlookup across multiple columns in one formula

questforexcel

Board Regular
Joined
Jan 18, 2019
Messages
128
Office Version
  1. 2013
Platform
  1. Windows
Hi All,

I was trying to vlookup my data from a table with 4 columns, when I applied the following formula there were errors in a few of the calculations.

IFERROR(VLOOKUP(LEFT(A4007,3),'USPS - Zone & Pricing Chart'!$B$4:$I$34,2,1),IFERROR(VLOOKUP(LEFT(A4007,3),'USPS - Zone & Pricing Chart'!$B$4:$I$34,4,1),IFERROR(VLOOKUP(LEFT(A4007,3),'USPS - Zone & Pricing Chart'!$B$4:$I$34,6,1),IFERROR(VLOOKUP(LEFT(A4007,3),'USPS - Zone & Pricing Chart'!$B$4:$I$34,8,1),"Not Found"))))

However, when I place all data in one single column, it picks the right values and figures.

Could you please help me to solve this.


I would like it to pick the values from the 4 column table and pick the right ones.
 
Thank you, this worked :)

However, just curious, is there no other way, to make excel lookup across different columns through one formula?

Would I always have to manually shift data into 2 columns.

Thank you

My suggestion is to modify your "USPS - Zone & Pricing Chart" to have two columns instead of 8. Take the data of columns C&D and put under A&B, likewise with E&F and G&H

Code:
=INDEX([COLOR=#574123][I]'USPS - Zone & Pricing Chart'![/I][/COLOR]$B$2:$B$181,MATCH(LEFT(A4007,3),[COLOR=#574123][I]'USPS - Zone & Pricing Chart'![/I][/COLOR]$A$2:$A$181,1))
Note: change 181 to be the last row of your concatenated columns of 'USPS - Zone & Pricing Chart'
 
Upvote 0

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
try this that don't need to rearrange your data


Book1
ABCDEFGH
1Postal Code
225757
376328
493149
5
6
7ZIP CodeZoneZIP CodeZoneZIP CodeZoneZIP CodeZone
8005-07663141*3141*3141*
9775350---3524350---3524350---3524
10078---0796354---3684354---3684354---3684
11080---0875369---3945760---7658369---3945
12088---0896395439543954
13090---0986+396---3975396---3975396---3975
14100---14963984*3984*3984*
15150---1665399439949319
161676400---4185400---4185400---4185
17168---2125420---4275420---4275420---4275
18214---2687430---4335420---4285430---4335
19270---2795434---4366434---4366434---4366
20280---2854437---4625437---4625437---4625
Sheet1
Cell Formulas
RangeFormula
B2=SUMPRODUCT(--(LEFT($A2,3)>=LEFT($A$8:$A$20,3)),--(LEFT($A2,3)<=RIGHT($A$8:$A$20,3)),$B$8:$B$20) +SUMPRODUCT(--(LEFT($A2,3)>=LEFT($C$8:$C$20,3)),--(LEFT($A2,3)<=RIGHT($C$8:$C$20,3)),$D$8:$D$20) +SUMPRODUCT(--(LEFT($A2,3)>=LEFT($E$8:$E$20,3)),--(LEFT($A2,3)<=RIGHT($E$8:$E$20,3)),$F$8:$F$20) +SUMPRODUCT(--(LEFT($A2,3)>=LEFT($G$8:$G$20,3)),--(LEFT($A2,3)<=RIGHT($G$8:$G$20,3)),$H$8:$H$20)
 
Upvote 0
Very nice! Caution: there's one value that you want to make text: A9 = 77 should be '077, and I assume that your zip lookup will extend to the west coast (900's) so the $20 would become whatever the last row is for the 8 columns.
 
Upvote 0
I played around with that formula and found that if the zone column had a non-numeric (i.e. '2*' or '9+') it returned zero. I also found a zone chart from the post office (https://postcalc.usps.com/domesticzonechart). Please modify the lookup ranges if necessary, the fourth column set was two rows less than the other three.

Here's a revised format using separate tab for the lookup chart:
Code:
=SUMPRODUCT(--(LEFT(A2,3)>=LEFT('USPS - Zone & Pricing Chart'!$A$2:$A$36,3)),--(LEFT(A2,3)<=RIGHT('USPS - Zone & Pricing Chart'!$A$2:$A$36,3)),--LEFT('USPS - Zone & Pricing Chart'!$B$2:$B$36,1))
+SUMPRODUCT(--(LEFT(A2,3)>=LEFT('USPS - Zone & Pricing Chart'!$C$2:$C$36,3)),--(LEFT(A2,3)<=RIGHT('USPS - Zone & Pricing Chart'!$C$2:$C$36,3)),--LEFT('USPS - Zone & Pricing Chart'!$D$2:$D$36,1))
+SUMPRODUCT(--(LEFT(A2,3)>=LEFT('USPS - Zone & Pricing Chart'!$E$2:$E$36,3)),--(LEFT(A2,3)<=RIGHT('USPS - Zone & Pricing Chart'!$E$2:$E$36,3)),--LEFT('USPS - Zone & Pricing Chart'!$F$2:$F$36,1))
+SUMPRODUCT(--(LEFT(A2,3)>=LEFT('USPS - Zone & Pricing Chart'!$G$2:$G$34,3)),--(LEFT(A2,3)<=RIGHT('USPS - Zone & Pricing Chart'!$G$2:$G$34,3)),--LEFTI'USPS - Zone & Pricing Chart'!$H$2:$H$34,1))
 
Upvote 0
It was very observant of you to point that out.

I had worked on all the data but was still getting #NA on my file, when i filtered it was all the "77" orders.

I manually put that out to '077 and it worked :) Thanks

Very nice! Caution: there's one value that you want to make text: A9 = 77 should be '077, and I assume that your zip lookup will extend to the west coast (900's) so the $20 would become whatever the last row is for the 8 columns.
 
Upvote 0
Thank you so much for this, the left only 1 char for Zone column was helpful. :)

Alan Y's formula and your improvisation really saved my day.

If its okay with you, could you please help me understand the following:

1) I'd been reluctant to use the sumproduct formula cause of lack of knowledge on it.

Does sum product combine only 2 sets of data i.e. Left 3 characters of the zone and right 3 characters of the zone against one reference point i.e. the zone value. If I had more dependent factors, could it have even factored those to match against one reference point of the zone value?

2) This is relatively a simple question, what does the "--" before the left sign signify.

I played around with that formula and found that if the zone column had a non-numeric (i.e. '2*' or '9+') it returned zero. I also found a zone chart from the post office (https://postcalc.usps.com/domesticzonechart). Please modify the lookup ranges if necessary, the fourth column set was two rows less than the other three.

Here's a revised format using separate tab for the lookup chart:
Code:
=SUMPRODUCT(--(LEFT(A2,3)>=LEFT('USPS - Zone & Pricing Chart'!$A$2:$A$36,3)),--(LEFT(A2,3)<=RIGHT('USPS - Zone & Pricing Chart'!$A$2:$A$36,3)),--LEFT('USPS - Zone & Pricing Chart'!$B$2:$B$36,1))
+SUMPRODUCT(--(LEFT(A2,3)>=LEFT('USPS - Zone & Pricing Chart'!$C$2:$C$36,3)),--(LEFT(A2,3)<=RIGHT('USPS - Zone & Pricing Chart'!$C$2:$C$36,3)),--LEFT('USPS - Zone & Pricing Chart'!$D$2:$D$36,1))
+SUMPRODUCT(--(LEFT(A2,3)>=LEFT('USPS - Zone & Pricing Chart'!$E$2:$E$36,3)),--(LEFT(A2,3)<=RIGHT('USPS - Zone & Pricing Chart'!$E$2:$E$36,3)),--LEFT('USPS - Zone & Pricing Chart'!$F$2:$F$36,1))
+SUMPRODUCT(--(LEFT(A2,3)>=LEFT('USPS - Zone & Pricing Chart'!$G$2:$G$34,3)),--(LEFT(A2,3)<=RIGHT('USPS - Zone & Pricing Chart'!$G$2:$G$34,3)),--LEFTI'USPS - Zone & Pricing Chart'!$H$2:$H$34,1))
 
Upvote 0
Thank you so much for this, the left only 1 char for Zone column was helpful. :)

Alan Y's formula and your improvisation really saved my day.

If its okay with you, could you please help me understand the following:

1) I'd been reluctant to use the sumproduct formula cause of lack of knowledge on it.

Does sum product combine only 2 sets of data i.e. Left 3 characters of the zone and right 3 characters of the zone against one reference point i.e. the zone value. If I had more dependent factors, could it have even factored those to match against one reference point of the zone value?

2) This is relatively a simple question, what does the "--" before the left sign signify.

1) sumproduct() function can deal with multiple sets of data, it just multiply them up similar to the AND function. to get the OR effect it need to add the individual sumproduct results like the one in post #12

2) the -- in front of the function is to turn the array(true, true, false, etc) to (1,1,0, etc) so that excel can add them up
 
Upvote 0
the -- in front of the function is to turn the array(true, true, false, etc) to (1,1,0, etc) so that excel can add them up
This is the real genius part (thanks to AlanY) - setting to a binary array (0's & 1's) would only return a value when the first three digits of the zip are between the values in the lookup and BOTH were 1 (true) being 1*1, every other situation would be 1*0.
The "--" in front of the Left(zone,1) turned it from text to numeric so it could be multiplied [how that worked I'm not really sure].
 
Upvote 0

Forum statistics

Threads
1,223,268
Messages
6,171,100
Members
452,379
Latest member
IainTru

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