HomeGoogle DocsSpreadsheetHow to Skip Blank Cells in Vlookup in Google Sheets

How to Skip Blank Cells in Vlookup in Google Sheets

Published on

You can very easily skip blank cells in Vlookup in Google Sheets. You can either use the FILTER function or the QUERY function together with Vlookup in Google Sheets.

It may not be as much simpler in Excel since the lack of these two functions. Now about how to skip blank cells in Vlookup.

Vlookup searches down the first column in a table for your given search key. If found, the formula would return value from any cell in that found row. This you may already know.

The returned cell value can be any values (text, numeric or date) or may sometimes blank. If the cell is blank, Vlookup doesn’t skip the row. Instead, it would return blank. But you can skip blank rows in Vlookup.

Then how to skip blank cells in Vlookup in Google Sheets?

Example: Skip Blank Cells in Vlookup in Google Sheets

In the above example, my lookup search key is “B”. I want a Vlookup formula that would search down Column A for the value “B” and return value from the same row in column B. If you use Vlookup in this case, it would return blank.

=vlookup(D1,A1:B7,2,FALSE)

As you can see, Vlookup will find the search key “B” in cell A2. What we want is the result of column B in that row. That means the value in cell B2.

Here, cell B2 doesn’t contain any value and it’s blank. So Vlookup will only return blank. I want to skip this row and search for the second appearance of “B” in column A, i.e. in cell A5 and return the value from B5 since it’s not blank. How?

How to Skip Blank Cells in Vlookup in Google Sheets

You can tweak Google Sheets Vlookup function in many ways. Skipping blank cells are also possible.

You can use Vlookup to return an Array result, for Image Lookup, to Return Multiple Columns, Case Sensitive Vlookup etc.

If you are interested to learn advanced Vlookup formulas, I suggest you search this page using the search term “Vlookup” in the search field that you can find on the top of this page.

The Formula to Skip Blank Cells in Vlookup

The below Vlookup formula is based on the above Sample data and cell references. This Vlookup formula can skip blank cells.

=VLOOKUP(D1,query(A1:B7,"Select * where B is not null"),2,FALSE)

Before taking you to the formula explanation, first, we can see the Vlookup Syntax.

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

If you analyze the formula, you can understand that in my formula that to skip blank cells in Google Sheets, the “range” is not a direct table/array reference. Instead, it’s replaced by a Query formula. This Query is the soul of my formula. What does it do?

The Query part in the above formula, filtered out rows that contain no values (blank) in column B. Here is that Query formula result for your reference.

Query in Google Sheets Vlookup

This’s our actual Vlookup range and the Vlookup formula searches down column 1 in this table to find the search key “B” and properly return the value from Column B.

This time since there are no blank cells, there is no issue with the blank cell as output. That’s all. This way you can skip blank cells in Vlookup in Google Sheets. Enjoy!

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Guide Prashanth KV brings a wealth of experience in Google Sheets and Excel, cultivated through years of work with multinational corporations in Mumbai and Dubai. As a recognized Google Product Expert in Docs Editors, Prashanth shares his expertise through insightful blogging since 2012. Explore his blog for practical tips and guidance on maximizing your spreadsheet skills.

Dynamic Sum Column in SUMIF in Google Sheets

To obtain a dynamic sum column (sum_range argument) in SUMIF, we can utilize the...

Create a Calendar in Excel with a One-Line Dynamic Array Formula

This tutorial explains how to create a calendar in Excel using a one-line formula...

Excel: Month Name to Number & Number to Name

This tutorial showcases the most efficient formulas for converting a month name to a...

Get the First or Last Row/Column in a New Google Sheets Table

If you've recently started using the new Google Sheets TABLE functionality, you may find...

More like this

Dynamic Sum Column in SUMIF in Google Sheets

To obtain a dynamic sum column (sum_range argument) in SUMIF, we can utilize the...

Get the First or Last Row/Column in a New Google Sheets Table

If you've recently started using the new Google Sheets TABLE functionality, you may find...

UNIQUE Function in Visible Rows in Google Sheets

The UNIQUE function doesn't inherently include only visible rows when it returns values, discarding...

5 COMMENTS

  1. Hi Prashanth,

    Thanks for the article! What do I do when my search key is not “B” but a random string which also constantly changes when I copy the formula to other cells? How would I have to tweak the “Select * where B is not null” part? Thanks!

  2. Thanks for the interesting post. Is it possible that if VLOOKUP one column blank then it automatically selects the next column? If yes, please let me know.

    Thanks

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.