How to Import Matching Values Using Vlookup and Importrange in Google Sheets

Are you looking to import matching values from one spreadsheet to another in Google Sheets? Well, you’re in luck! In this tutorial, we’ll explore how to use the powerful combination of Vlookup and Importrange functions to achieve just that. And hey, if you already have some experience with Vlookup and Importrange, this will be a piece of cake for you.

Vlookup and Importrange: A Match Made in Google Sheets

Many Google Sheets users wonder if they can use Vlookup+Importrange or Query+Importrange to conditionally import data between two Sheets files. The answer is a resounding yes! Both combinations can be used, but there are some differences to keep in mind. Don’t worry, we’ll explain everything.

In this advanced tutorial, we’ll not only cover how to use Vlookup in Importrange but also dive into how to utilize Query in Importrange. By the end of this journey, you’ll have a solid understanding of how to make the most of these functions in Google Sheets.

But hold on a second! We know you’re not new to Vlookup or Importrange. You’re here because you want to take your skills to the next level. However, if you think it’s time to brush up on your Vlookup/Importrange game, be sure to check out our comprehensive Google Sheets Functions guide.

Now, let’s get down to business and explore some exciting tips on Vlookup and Importrange!

How to Vlookup Using Importrange in Google Sheets

To illustrate how this works, let’s consider two Google Sheets files: “Sales” and “Analysis.” Our goal is to import data from the “Sales” file into the “Analysis” file using the Vlookup+Importrange combination.

In the “Sales” file, we have the following sample data in “Sheet1”:

Sales (Sample)

|   A   |       B       |     C     |     D     |     E     |      F       |
|-------|---------------|-----------|-----------|-----------|--------------|
|       |  First Name   | Last Name |   Item    |  Quantity |    Price     |
|   1   |    Justin     |  Jackson  | Shampoo   |     2     |    10.00     |
|   2   |    Andrew     |  Edwards  |  Soap     |     3     |    5.00      |
|   3   |   Jonathan    |   Reed    | Toothpaste|     1     |    7.00      |

Now, in the “Analysis” file, let’s learn how to search for values in “Sheet1” of the “Sales” file and return the corresponding values.

Basic Example of Vlookup with Importrange

Let’s say we have the search key “Justin” in cell A2 of the “Analysis” file. Our aim is to use Vlookup to find this name in column A of “Sheet1” in the “Sales” file and return the corresponding value from column F.

Here’s how you can achieve this:

  1. Open the “Sales” workbook and copy the Spreadsheet URL from the address bar. Make sure the active tab is “Sheet1,” which contains the data we want to look up.

  2. In the “Analysis” file, insert the following Importrange formula in cell B1:

    =IMPORTRANGE("URL","Sheet1!A1:F")

    Remember to replace “URL” with the copied Spreadsheet URL.

  3. If you see a #REF error, hover over it and click “Allow access” to import data from the source sheet (“Sales”) to the destination sheet (“Analysis”).

  4. Wrap the Importrange formula with the Vlookup function as follows:

    =VLOOKUP(A2,B1:F,6,FALSE)

    The Vlookup looks for the search key (A2) in the imported range (B1:F) and returns the value from column 6 (price) in this case.

Anatomy of the Vlookup Formula

Here’s a breakdown of the different elements in the Vlookup formula we just used:

  • search_key: A2
    Cell A2 in the “Analysis” file contains the search key, which in this case, is the name “Justin.”

  • range: B1:F
    The range parameter represents the lookup range, which is in another file, namely “Sales.”

  • index: 6
    The index value signifies the column number (6 refers to column F), from which Vlookup returns the value.

  • is_sorted: FALSE
    This flag ensures an exact match of the search key in the first column of the table.

This example showcases the basic usage of Vlookup and Importrange. Now, let’s explore more advanced scenarios.

Vlookup and Importrange with Multiple Search Keys

Vlookup+Importrange supports various advanced Vlookup flavors, including multiple search keys. The formula might seem complex due to the replacement of the Vlookup range with Importrange, but fear not! We’ll break it down for you.

Let’s say we have multiple search keys in column A2:A4 of the “Analysis” file. Here’s how you can use Vlookup in Importrange to handle these multiple search values:

=ARRAYFORMULA(IFERROR(VLOOKUP(A2:A,IMPORTRANGE("URL","Sheet1!A1:F"),6,0)))

This formula is an array formula, meaning we expect an array result from Vlookup. To achieve this, we wrap the formula in the ARRAYFORMULA function.

In this case, A2:A4 represents the search keys, and the Importrange formula retrieves the data from “Sheet1” of the “Sales” file. Vlookup searches for each search key in the imported data and returns the corresponding value from column 6. We use IFERROR to avoid any #N/A errors.

Using Multiple Conditions in Vlookup and Importrange

In regular Vlookup usage, the formula searches down the first column of a range. However, what if you want to search down two columns in an imported range? That’s where multiple conditions in Vlookup+Importrange come into play.

Let’s say we want to search for matching values based on the first name (column A) and last name (column B) in the “Analysis” file. Here’s the formula you can use:

=ARRAYFORMULA(VLOOKUP(A2:A&B2:B,{IMPORTRANGE("URL","Sheet1!A2:A")&IMPORTRANGE("URL","Sheet1!B2:B"),IMPORTRANGE("URL","Sheet1!C2:F")},5,FALSE))

Make sure to replace all three URLs in the formula with the URL of the “Sales” file.

The logic behind this formula is as follows:

  1. We join, combine, or concatenate the search keys using the ampersand sign.
  2. Next, we join the related columns in the Vlookup range using the ampersand sign.
  3. Since we combined two columns in the range, we have only five columns left. Hence, we use column index number 5 instead of 6 in Vlookup.

The formula might seem a little overwhelming at first, but with a bit of practice, you’ll master it in no time.

Performance Enhancement Using LET

Using multiple Importrange formulas can impact performance and slow down calculations. However, fear not! We have a solution for you. The new LET function comes to the rescue and helps improve performance.

Here’s how you can rewrite the earlier formula using LET:

=ARRAYFORMULA(LET(sk,A2:A&B2:B,rg,IMPORTRANGE("URL","Sheet1!A2:F"),VLOOKUP(sk,{CHOOSECOLS(rg,1)&CHOOSECOLS(rg,2),CHOOSECOLS(rg,{3,4,5,6})},5,0)))

In this formula, we use the LET function to introduce two named variables: sk for the Vlookup search keys and rg for the Importrange formula.

The formula expression part of the LET function contains the Vlookup formula. We use the CHOOSECOLS function to extract specific columns from the imported range and combine the first two search columns.

This implementation of the LET function enhances performance and reduces the need for multiple Importrange formulas.

Alternative: Xlookup and Importrange

Here’s an interesting twist! Instead of Vlookup, you can also use the XLOOKUP function with Importrange to import values.

=ARRAYFORMULA(LET(sk,A2:A&B2:B,rg,IMPORTRANGE("URL","Sheet1!A2:F"),XLOOKUP(sk,CHOOSECOLS(rg,1)&CHOOSECOLS(rg,2),CHOOSECOLS(rg,6))))

In this case, we use the XLOOKUP function to find the values. The argument structure is simplified, as we only need the search key, lookup range, and result range.

Query: A Vlookup+Importrange Alternative

If you’re looking for an alternative to Vlookup, the Query function can come in handy. You can leverage its filtering capabilities to achieve the desired results in a second sheet based on the first sheet.

Let’s consider an example:

=Query(IMPORTRANGE("URL","Sheet1!A2:F"),"Select Col6 where Col1='"&A2&"'")

This formula searches for the search key “Justin” in cell A2 of the “Analysis” file. Query matches this value in the imported data (“Sales” file) and returns the corresponding value from column 6.

If you have multiple search keys in column A, you can simply drag this formula down. Alternatively, you can use Matches regular expressions to include all search keys in one go.

Conclusion

In summary, the Query function in Importrange has its advantages, particularly when it comes to simplicity and ease of use. However, Vlookup and Importrange offer far more versatility and the ability to quickly populate an array result.

To optimize your performance and achieve seamless lookup operations using multiple Importrange formulas, the LET function is your go-to companion. It allows you to combine multiple formulas into a single powerful expression.

We hope this guide has shed light on the fantastic capabilities of Vlookup and Importrange in Google Sheets. Remember, practice makes perfect! So go ahead, explore these functions, and become a master of data manipulation in Google Sheets.

And, if you want to learn more juicy secrets about Google Sheets and other useful tools, head over to Crawlan.com for more exciting articles and tips. Happy sheeting!

Related posts