How to use VLOOKUP with IMPORTRANGE in Google Sheets

Combining the power of VLOOKUP and IMPORTRANGE is a great way to transfer specific data between two spreadsheets. Expand the horizons of both functions and apply vlookup across Google Sheets.

Continue reading to use VLOOKUP across Google Sheets and discover how Sheetgo, an AI-powered data automation platform, offers an alternative that needs no formulas.

If the data you want to look up is in another tab of the same file, you don’t need IMPORTRANGE. Our guide to VLOOKUP from another sheet or workbook covers that case.

An overview of IMPORTRANGE

Let’s review how IMPORTRANGE works. It’s straightforward and only needs two arguments: the URL of the source spreadsheet and the range to import from it.

=IMPORTRANGE(spreadsheet_url, range_string)

A few pointers to keep in mind:

  • You must wrap both arguments in quotation marks.
  • You need view access to the source spreadsheet.
  • This function will return a REF error the first time it runs. To solve it, click the cell that contains the error and then allow access to the source spreadsheet.

Check out our ultimate guide to IMPORTRANGE.

Understanding VLOOKUP

The VLOOKUP function searches across a range, one row at a time. If it finds a specific value in the first column, it returns a value in the same row from a specified column. As its name indicates, it’s commonly used to look up data.

It takes four arguments:

  • search_key: the value to match.
  • range: the cell coordinates to search.
  • index: the column offset that indicates which values to return.
  • [is_sorted]: whether the data is sorted. If unsure, set this to “FALSE” for good measure.

=VLOOKUP(search_key, range, index, [is_sorted])

Combining VLOOKUP and IMPORTRANGE

Using these two functions together allows us to apply VLOOKUP between two Google Sheets. Something that would be impossible otherwise.

The idea is simple, we just have to use IMPORTRANGE as the VLOOKUP range. Below is the basic syntax for this combination.

=VLOOKUP(search_key, IMPORTRANGE(spreadsheet_url, range_string), index, FALSE)

Let’s take a look at what that formula would look like with real information.

=VLOOKUP(A3, IMPORTRANGE("2JLmFDIKcZPATrjWF_9js8Pvw3d2mWzSzYypB1s4z8uo", "follow_up!A:B"), 2, FALSE)

This approach is good for importing small data sets. However, if working with large spreadsheets, it’s better to use VLOOKUP on the source spreadsheet and import the result.

Below, you have step-by-step instructions on how to get values from a different spreadsheet using VLOOKUP and IMPORTRANGE.

Copy the source URL and cell range

The source file used in the examples contains customer information, including their ‘customer_id’. The destination file contains information on transactions identified by ‘customer_id’. This allows me to import data from the source file using ‘customer_id’ as the search key.

1. Open both the source and destination files in Sheets.

VLOOKUP with IMPORTRANGE in Google Sheets — TRANSACTIONS file with customer_id, transaction_amount and product columns
VLOOKUP with IMPORTRANGE in Google Sheets — CUSTOMERS file with customer_id, first_name, last_name and email columns

2. From the source file, copy the URL.

VLOOKUP with IMPORTRANGE in Google Sheets — CUSTOMERS file URL selected in the address bar, with Copy highlighted

3. Paste the URL into the destination file.

VLOOKUP with IMPORTRANGE in Google Sheets — source URL pasted into cell B1 of the TRANSACTIONS file

4. Go back to the source file and select the cell range. You can copy the cell range reference from the top-left corner, as shown below.

VLOOKUP with IMPORTRANGE in Google Sheets — range A1:D301 selected in the CUSTOMERS file, with Copy highlighted

5. Paste the cell range reference into the destination file. I won’t specify the sheet in this case because I’m only using “Sheet1”.

VLOOKUP with IMPORTRANGE in Google Sheets — range A1:D301 pasted into cell B2 of the TRANSACTIONS file

Add the VLOOKUP function

1. In the cell where you want the return value, start typing the VLOOKUP formula.

VLOOKUP IMPORTRANGE formula — VLOOKUP started in cell D5 under the firstname column

2. For the 1st argument, select the search key.

VLOOKUP IMPORTRANGE formula — cell A5 with the customer_id selected as the search key

3. For the 2nd argument, add the IMPORTRANGE formula, referring to the cells where you copied the URL and cell range.

VLOOKUP IMPORTRANGE formula — IMPORTRANGE(B1,B2) added as the VLOOKUP range

4. Add the column index, enter FALSE as the last argument to get an exact match, and close the parenthesis.

VLOOKUP IMPORTRANGE formula — column index 2 added and the last argument left blank

5. Press enter to see the result.

VLOOKUP IMPORTRANGE formula — first name Brier returned in cell D5

Approve access between the two files

If you’re working with files that have never been connected before, you’ll see an error message instead of the value when you press ‘Enter’. To see the actual value, click the cell with the #REF! error, then click Allow access.

VLOOKUP IMPORTRANGE formula — #REF! error with You need to connect these sheets and the Allow access button

VLOOKUP with IMPORTRANGE for multiple search values

One VLOOKUP returns one value. To fill a whole column, you can copy the formula down with autofill, or wrap it in ARRAYFORMULA so a single formula covers every row. ARRAY_CONSTRAIN then removes the errors that ARRAYFORMULA returns for empty rows.

Copy the formula with autofill

For the sake of simplicity, I’ll build on the example used in the previous section.

1. Add the VLOOKUP formula and select the search key as the 1st argument, using absolute referencing for the column.

VLOOKUP with IMPORTRANGE and autofill — $A5 used as the search key, with the column locked

2. Use IMPORTRANGE as the 2nd argument, with the source URL and cell range reference as the arguments. Use absolute referencing for both columns and rows.

VLOOKUP with IMPORTRANGE and autofill — IMPORTRANGE added with absolute references to the URL and range cells

3. Specify the index for the column with the result you want, and enter FALSE as the 4th argument for an exact match.

VLOOKUP with IMPORTRANGE and autofill — column index 2 added to the formula in cell D5

4. Press enter to see the result.

VLOOKUP with IMPORTRANGE and autofill — Brier returned in cell D5 of the firstname column

5. Double-click on the fill handle circled in red below.

VLOOKUP with IMPORTRANGE and autofill — fill handle circled in red and first names filled down column D

6. To import values from the column to the right, grab the fill handle shown in the screenshot above and drag right.

VLOOKUP with IMPORTRANGE and autofill — formula dragged right into cell E5, still returning Brier

7. Double-click to modify the formula to import from the 3rd column instead of the 2nd.

VLOOKUP with IMPORTRANGE and autofill — column index changed to 3 in the formula in cell E5

8. Press “Enter” to see the result. Google Sheets will automatically suggest Autofill, but if not, you can double-click on the fill handle again.

VLOOKUP with IMPORTRANGE and autofill — last names in column E with the Suggested autofill prompt

Going a step further with ARRAYFORMULA

The VLOOKUP can only be applied to one search key at a time. That means you would have to copy-paste it across necessary cells. To avoid this, we can add ARRAYFORMULA. 

The formula below is an improved version. It includes this other function and provides a range for the VLOOKUP search key.

=ARRAYFORMULA(VLOOKUP(A3:A, IMPORTRANGE(“2JLmFDIKcZPATrjWF_9js8Pvw3d2mWzSzYypB1s4z8uo”, “follow_up!A:B”), 2, FALSE))

The steps below build the same kind of formula for the customer data from the autofill example.

1. In the cell where you want the result, start with the ARRAYFORMULA function.

VLOOKUP with IMPORTRANGE and ARRAYFORMULA — ARRAYFORMULA started in cell D5

2. Add the VLOOKUP formula and select the range of values you want to look up.

VLOOKUP with IMPORTRANGE and ARRAYFORMULA — $A$5:$A$301 selected as the search key range

3. Add IMPORTRANGE, using absolute referencing for the cells.

VLOOKUP with IMPORTRANGE and ARRAYFORMULA — IMPORTRANGE($B$1,$B$2) added as the VLOOKUP range

4. Specify the index for the column with the result you want, and enter FALSE as the last argument to get an exact match.

VLOOKUP with IMPORTRANGE and ARRAYFORMULA — column index 2 added and the formula closed

5. Press enter to see the result. If you see an error, remember to approve access between the two Sheets files.

VLOOKUP with IMPORTRANGE and ARRAYFORMULA — first names returned for every row of column D

6. To import the values from the next column, grab the fill handle and drag the formula right. Double-click to edit the column index.

VLOOKUP with IMPORTRANGE and ARRAYFORMULA — formula copied to cell E5 with index 3, returning last names

Unfortunately, an open-ended range like A3:A also introduces an issue: the arrayformula returns a series of errors if information is missing.

Cleaning up with ARRAY_CONSTRAIN

The errors introduced by the last modification can be fixed by constraining the number of rows in the array. For that we will use ARRAY_CONSTRAIN to add this limitation. Again, the modifications are in bold.

=ARRAY_CONSTRAIN(ARRAYFORMULA(VLOOKUP(A3:A, IMPORTRANGE(“2JLmFDIKcZPATrjWF_9js8Pvw3d2mWzSzYypB1s4z8uo”, “follow_up!A:B”), 2, FALSE)), COUNTA(A3:A), 1)

The only significant change in this formula is the use of COUNTA for the number of rows. This function will count all the cells containing values that VLOOKUP can try to match.

And that’s the final iteration of this formula, these final changes made it simpler and more efficient.

Common errors with VLOOKUP and IMPORTRANGE

  • The first time you link two files, the formula returns #REF! until you click the cell and choose Allow access. If the error stays, make sure you have at least view access to the source spreadsheet.
  • #N/A means VLOOKUP didn’t find the search key in the first column of the imported range. Check that the range starts with the column that holds your keys, and look for extra spaces in the values.
  • A #REF! error that mentions an out of bounds range means the index is larger than the number of columns you import. With the range follow_up!A:B, the index can only be 1 or 2.
  • Large imports slow a spreadsheet down. If yours lags, run VLOOKUP in the source spreadsheet and import only the results.

For errors that come from IMPORTRANGE itself, see how to fix IMPORTRANGE not working.

Common use cases

Using both VLOOKUP and IMPORTRANGE can significantly enhance your data management. Here are some use cases that highlight how this combination could be useful.

Employee Information

  • Case: Human Resources keeps employee records in one spreadsheet, but each department has separate project assignment sheets.
  • Solution: Import employee records into department-specific sheets, then match project assignments with employee details like names and positions.

Inventory Management

    • Case: Your company has several warehouses, each maintaining its own inventory spreadsheet.
    • Solution: Import data from each warehouse’s sheet into a master inventory tracker, find stock levels and item details across all locations.

    Financial Analysis

    • Case: You manage multiple client accounts, each with its own financial records spreadsheet.
    • Solution: Import and aggregate financial data from all client sheets into one. Afterwards, look up financial metrics to analyze (for example, total revenue, expenses, and profit margins per client).

    With the power of VLOOKUP and IMPORTRANGE on your side, you can manage and analyze data across multiple spreadsheets.

    Using Sheetgo to transfer and process data

    Unfortunately relying heavily on both of these functions can be problematic. Importrange breaks often and slows down spreadsheets.

    We have a solution: Sheetgo, an AI-powered data automation platform. Its connections can transfer data like IMPORTRANGE and process it like VLOOKUP. But it’s more efficient, as it allows you to configure when to transfer the data. It also gives you a lot of processing options and allows you to introduce forms to gather data.

    Since Sheetgo is a no-code tool you can forget about using and maintaining all these complicated functions. Just set up your connections and keep important data close at hand.

    Cut out data handling tasks and free up time for more important tasks, try out Sheetgo today.

    Other functions to pair with IMPORTRANGE

    When you need every row that meets a condition rather than one value per key, see how to combine QUERY and IMPORTRANGE or how to filter IMPORTRANGE. If you’re new to lookups across files, our guide on how to VLOOKUP between two Google Sheets starts with a lookup between two tabs of the same file.

    You may also like…

    google sheets features and formulas

    How to find nominal interest rate using Google Sheets

    Sarah is a young professional making significant financial decisions. From credit cards to mortgages, student loans, and investment...
    google sheets features and formulas

    Pull Google Calendar data into Google Sheets using Apps Script

    This post was originally published in our community forum. Objective : This guide demonstrates how to use Google Apps Script to pull data...
    google sheets features and formulas

    Using the PROPER function to capitalize the first letter of each word in Google Sheets

    Note: This post was originally published in our community forum. Ever found yourself needing to clean up a list of names, titles, or any...