Combine a VLOOKUP and IF Formula depending on Search Criteri

DougStroud

Well-known Member
Joined
Aug 16, 2005
Messages
2,976
Office Version
  1. 365
Platform
  1. MacOS
Good Morning,
I am working on combining a VLOOKUP and IF Formula and need some assistance.

I am looking to return a shipping weight depending on the item type, the problem I am having is this; the item may be in a category or it may be in a sub-category.

If the item type resides in the category, no problem, my VLOOKUP finds the shipping weight. If the item type is classfied down one more level in a sub-category the VLOOKUP needs to look here.

If the item type has no sub-category listing, then this field is blank. I was thinking of accomplishing this by combining an IF formula that basically says look in the sub-category field first, if nothing exists, look in the category field.
Column V= Category Field
Column W= Sub-Category Field

Attempted Formula yielded a #NA Result:
Formula in full is below:

=IF(VLOOKUP(W4,'[Departments & Categories.xls]Shipping Weights'!$B$1:$D$324,2,FALSE)="",VLOOKUP(V4,'[Departments & Categories.xls]Shipping Weights'!$B$1:$D$324,2,FALSE))

O4 shows the #NA Result using the IF and VLOOKUP
P4 shows the VLOOKUP w/o the IF. It is listing the Item Type's Actual Weight and this Item Type does not have a sub-category so, no problem. But the following two items have sub-categories, so the my combined formula is required. But, I am only using the VLOOKUP here, not the combined/nested formula that will be required to return the correct shipping and actual weight.

HTML View:
EC-Orphans(10-24_04-56)b.xls
ABCDEFGHIJKLMNOPQRSTUVWX
3SKUNameUse this column to change sizingParent SKUDescriptionSpecsURLPriceSale PriceColorSizeTrim 1Trim 2Trim 3s/h Weightactual WeightDate AvailDate AddedQtyManufacturerDeptCategorySubcategoryRe Orderable
441165411 SKATEBOARD DVD #6519.99#N/A0.52005-10-17 10:32:172411SkateVideosY
541165411 SKATEBOARD DVD #6519.9910.52005-10-17 10:32:172411AccessoriesVideosSkateY
6686RANGEBLKL686 RANGE JACKET RED L686RANGEBLK200L#N/A#N/A2005-10-17 10:38:061686SnowGuys OuterwearGuys JacketsY
EC Products


Thanks,

Doug S.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Try something like this:

=IF(W4="",VLOOKUP(V4,'[Departments & Categories.xls]Shipping Weights'!$B$1:$D$324,2,FALSE),VLOOKUP(W4,'[Departments & Categories.xls]Shipping Weights'!$B$1:$D$324,2,FALSE)


The reason you're returning N/A is because you're trying to lookup W4, which has no value. Therefore, you need 'IF(W4=""' at the beginning. If W4 is blank, the formula will lookup V4, but if W4 has a value, it will lookup VW4
 
Upvote 0
Vlookup & if

Hi Doug,

your formula is indeed not working... The problem is that the first part of your if statement:
=IF(VLOOKUP(W4,'[Departments & Categories.xls]Shipping Weights'!$B$1:$D$324,2,FALSE)="";
does not work properly. If your value cannot be found, the VLOOKUP will not respond with "", but with #N/A... So the second part of your if (false) will never be reached. Anyhow, the way to solve this is with the ISERROR() formula.
IF(ISERROR(VLOOKUP(W4,'[Departments & Categories.xls]Shipping Weights'!$B$1:$D$324,2,FALSE))=FALSE;VLOOKUP(W4,'[Departments & Categories.xls]Shipping Weights'!$B$1:$D$324,2,FALSE);"Here goes the other searcharea SubProduct")

Greetz,

Koen
 
Upvote 0
Thanks Njimack,

That worked. And, thanks for the explanation, its the old fish analogy....


Doug S.
 
Upvote 0
Koen,
Thanks, Njimack's submission hit it on the head.

Regards...
 
Upvote 0

Forum statistics

Threads
1,223,912
Messages
6,175,340
Members
452,638
Latest member
Oluwabukunmi

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