In Excel 2011 on Mac, how to return a non-blank matching value with vlookup?

1

I have a list of domain names and their registrars on one sheet, and the same list of domains and other data (but not registrars) on another sheet.

I need to get the registrar name from sheet A, to be next to the corresponding domain name in sheet B.

CSV example of sheet A:

domain1.com,,9.98,03/24/13
domain1.com,,9.98,03/24/13
domain1.com,godaddy,9.98,03/24/13
domain2.com,,9.98,03/24/13
domain2.com,godaddy,9.98,03/24/13
domain3.com,namecheap,9.98,03/24/13

CSV example of sheet B:

domain1.com,1200,04/01/14
domain2.com,402,04/01/14
domain3.com,612,04/01/14

I desire to have the registrar in a 4th column of sheet B for each domain.

The problem is that on sheet A, there are multiple instances of the domain where it was with other registrars in the past, but those cells have been erased. This causes my vlookup from sheet B, to find the first match of the domain name and return the corresponding registrar, which ends up being blank (returns zero).

Is there a way to get a VLookup (or other formula) to return only a corresponding registrar that is NOT blank?

I've experimented a bit with Index & Match but wasn't able to get any closer.

JVC

Posted 2014-04-07T18:58:39.933

Reputation: 309

Answers

1

You can use an array formula to do this look up. Where your original data is in A1:D6, you can use this formula (adjust sheet references to match your workbook):

=INDEX(SheetA!$B$1:$B$6,MIN(IF(SheetA!$A$1:$A$6=SheetB!A1,IF(SheetA!$B$1:$B$6="",2000000,ROW(SheetA!$B$1:$B$6)),2000000)))

Paste this into the formula bar and press Ctrl+Shift+Enter. Then fill down.

Explanation and assumptions:

  • The IF statements inside the MIN function form an array of numeric values. For records that meet the criteria (i.e., domain name matches and registrar is not blank) the row number of the record is stored in the array. For records that do not meet the criteria, the number 2000000 is stored in the array.
  • 2000000 is an arbitrary number greater than the number of rows in an Excel sheet. This is just to guarantee if no matches are found, the INDEX function will return an error.
  • INDEX returns the value at a specified position in an array.
  • The row number of the record is being used as a stand-in for the records position in the table. This is fine if the table begins in row 1 because record 1 is in row 1. However, if your data begins in a different row, you will need to tweak the formula to make this work. For instance, if record 1 is in row 2, you will need to substitute ROW($B$2:$B$7) with ROW($B$2:$B$7)-1. Otherwise, the INDEX function will return the wrong registrar.

Excellll

Posted 2014-04-07T18:58:39.933

Reputation: 11 857

This looks close... but I'm probably not understanding how to change the formula to work with my data. The data is on two different sheets, so assuming in your example A is for sheet A and B is for sheet B, I ended up with this formula which is returning something, but not the correct data and I can't really even figure out what it's returning. =INDEX(B:B,MIN(IF('domains'!A:A=B14,IF(B:B="",2000000,ROW(B:B)),2000000))) Also, where is this returning the row next to the matching value? I'm not seeing where that happens. – JVC – 2014-04-07T19:48:36.220

Sorry, that was confusing. I'll edit sheet references into my formula. – Excellll – 2014-04-07T20:49:12.023

I must still be screwing something up. This time I ended up with =INDEX('domains'!A:A,MIN(IF('domains'!A:A=B2,IF('domains'!A:A="",2000000,ROW('domains'!B:B)),2000000))) but I get a #REF error. This formula btw is supposed to go in sheet B yes? – JVC – 2014-04-07T21:08:35.350

Disregard previous comment, I had forgotten to make it an Array formula. Now it is returning the same incorrect information as before, basically nothing has changed. – JVC – 2014-04-07T21:09:58.053

OK I think I got it... had a typo. Will verify if this is working as I need it to and accept the answer if so. Thanks! – JVC – 2014-04-07T21:15:33.427

Well technically this works... however it is so slow as to be unusable. Inserting this formula and filling down seems to partially work, as some of the cells do get populated with the correct value, but only a tiny fraction of my 32,000 rows. Also as I click around, Excel seems to be continuing to do some lookups in the background because sometimes when I click in the "lookup" column, the value spontaneously changes to the correct value. How can I populate this array formula downwards to all 32,000 rows? – JVC – 2014-04-07T21:37:10.227

32,000 rows would have been some useful information to include in your post. Yes, array formulas are going to be slow with that much data. Is your data sorted or can it be sorted by domain? – Excellll – 2014-04-07T23:10:43.097

Sorry about that, I didn't realize the number of rows would be such an important factor. I've decided to just make a separate table of the information I need from sheet B, so that a normal VLookup will do the trick. But thanks for your help, I'll accept your question as the answer anyway since it technically did what I needed. – JVC – 2014-04-08T00:39:17.957