Help with Excel vlookup formula

etherealfocus

Senior member
Jun 2, 2009
488
13
81
Sorry if this doesn't count as programming - didn't know where else to post. Feel free to move this if needed, mods. :)

Anyway, here's the problem: I've got two Excel spreadsheets. One contains a list of 30,000 products with SKU, price, MAP (minimum advertising price), and some other data. I compiled the spreadsheet by downloading a dozen different reports from our web store back end - one report for each major product area, since the report generation fails if I try to get all 30k product records at once.

Many products are in multiple categories, so there are a lot of duplicates in my final product sheet.

The other spreadsheet is our upload form for a third party site we also sell on, and it has a clean list of UPCs that I got directly from our supplier's web service. Basically, our web store has a direct feed from our suppliers, and we take data from that site and crunch it to fit the needs of our other outlets. The data we get from our web store does not include UPCs, which we have to get directly from the supplier.

My sad task today is to merge these two sheets: long story short, I have UPCs and SKUs on my upload sheet and SKUs and MAPs on my product sheet.

I know how to make it happen: create a column in my upload sheet called MAP and fill it with VLOOKUP statements that match SKUs on the upload sheet to SKUs on the product sheets, then get the corresponding MAP. That should in theory avoid all the issues with duplicate records in the product sheet and avoid a messy process of filtering out duplicates, then sorting columns to match and copy-pasting.

Unfortunately, I just kinda suck at VLOOKUPs. I'm pretty decent at Excel, but never needed to use a VLOOKUP before now.

I've been reading the below articles for help:
http://www.howtogeek.com/howto/13780/using-vlookup-in-excel/
http://office.microsoft.com/en-us/excel-help/vlookup-HP005209335.aspx

I think the problem is probably just some stupid syntax goof, but it's late and I'm a bit fried and honestly I wouldn't be surprised if I just failed to grok the stupid instructions. :p

In my upload sheet, the SKU is in column A and the MAP field with the VLOOKUPs is in column B.

In my product sheet, the SKU is still column A and I moved the actual MAPs to column B for simplicity. Essentially, the VLOOKUP formula needs to get the value from an adjacent cell, lookup that value in the A column of the other sheet, and grab the value in the corresponding cell in the B column.

Maybe the problem is that it's essentially expecting a primary key field with unique values, but the values aren't unique in the product sheet because I have duplicates?

...I hate to ask because I expect the answer is yes, but is there an easier way to do this? Please just don't tell me I've been grinding the wrong function this entire time. :p
 

Tweak155

Lifer
Sep 23, 2003
11,449
264
126
VLookup should not be used for 30 thousand searches. That's a huge crunch on the workbook, and might even lock up the sheet.

While also slow, you can build your own search in VBA, but should be faster than VLookup.

It's been a while since I've even used VLookup, but did you try building it visually as in your first link?

EDIT:

Also you should handle the duplicates first. If they are in fact real duplicates (where everything is the same), eliminate the duplicates. Otherwise make the required changes.

EDIT EDIT:

Also you should show us what your vlookup attempt looks like, it's probably just a small change.
 
Last edited:

etherealfocus

Senior member
Jun 2, 2009
488
13
81
Here's my latest attempt (trying to KISS it):

=IF(ISERROR(VLOOKUP(A2,'ALL SSI'!B:C,2,TRUE)),"",)

This is a sheet we're gonna be updating and running daily though, so if we gotta VBA it then so be it.

Question: everyone who's gonna using this sheet is on Office 2013. Does that have any advantages re: VLOOKUP not being good for large files?
 

Jaydip

Diamond Member
Mar 29, 2010
3,691
21
81
VBA all the way man unless you need it absolutely macro free.
 

Tweak155

Lifer
Sep 23, 2003
11,449
264
126
Here's my latest attempt (trying to KISS it):

=IF(ISERROR(VLOOKUP(A2,'ALL SSI'!B:C,2,TRUE)),"",)

This is a sheet we're gonna be updating and running daily though, so if we gotta VBA it then so be it.

Question: everyone who's gonna using this sheet is on Office 2013. Does that have any advantages re: VLOOKUP not being good for large files?

Your lookup statement looks fine - the problem is your if statement. You don't actually return the value anywhere in the IF statement.

Try:

IF(ISERROR(VLOOKUP(A2,'ALL SSI'!B:C,2,TRUE)),"",VLOOKUP(A2,'ALL SSI'!B:C,2,TRUE))

This is an extremely bad way to do it, but should work. Also I would change the TRUE to FALSE unless partial matches are fine.

You are doing the search twice.
 

etherealfocus

Senior member
Jun 2, 2009
488
13
81
Haha ok. Well I put it on the boss' desk this morning since he's the self-proclaimed 'double black belt Excel ninja' lol, if he can't VLOOKUP it I'll go VBA.

Question: could it be done reasonably in Python? I'm a newbie at it but this'd be a worthwhile practice project.
 

Tweak155

Lifer
Sep 23, 2003
11,449
264
126
Haha ok. Well I put it on the boss' desk this morning since he's the self-proclaimed 'double black belt Excel ninja' lol, if he can't VLOOKUP it I'll go VBA.

Question: could it be done reasonably in Python? I'm a newbie at it but this'd be a worthwhile practice project.

This sounds like a good match for Python.

If you already have it pulling data into Excel though, I'd just get the simple searches going. It's less work to get the data matching it up than starting over in Python.
 

wetech

Senior member
Jul 16, 2002
871
6
81
Your lookup statement looks fine - the problem is your if statement. You don't actually return the value anywhere in the IF statement.

Try:

IF(ISERROR(VLOOKUP(A2,'ALL SSI'!B:C,2,TRUE)),"",VLOOKUP(A2,'ALL SSI'!B:C,2,TRUE))

This is an extremely bad way to do it, but should work. Also I would change the TRUE to FALSE unless partial matches are fine.

You are doing the search twice.

you can avoid doing the lookup twice in Excel 2007 and greater.

IFERROR(VLOOKUP(A2,'ALL SSI'!B:C,2,TRUE),"")