VLOOKUP Skips Hidden Rows in Google Sheets

Published on

The VLOOKUP function in Google Sheets searches all rows in the first column of the search range, irrespective of whether the rows are hidden or visible. However, sometimes you may want the VLOOKUP function to skip hidden rows when searching for a key in Google Sheets. In such cases, you should use a helper column with VLOOKUP.

The purpose of the helper column is to verify whether a row is hidden or not. We can create the helper column using the SUBTOTAL function, which works only with visible rows.

Preparing the Helper Column for VLOOKUP in Visible Rows Only

Assume you have sample data in A2:C8 with the columns Name, Advance Paid, and Date of Payment. You can use the range D2:D8 as the helper column.

In cell D3 (leaving the first row for headers), use the following SUBTOTAL formula and drag it down to cell D8:

=SUBTOTAL(103, A3)

This formula returns 1 for rows that are visible and 0 for hidden rows.

subtotal helper column for Vlookup visible rows

If you prefer not to use a drag-down formula, you can convert it into a custom LAMBDA function and use it with a MAP helper function to iterate through each row in the range.

To replace D3:D8, insert the following formula in cell D3:

=MAP(A3:A8, LAMBDA(val, SUBTOTAL(103, val)))

The MAP helper function applies the custom LAMBDA function (LAMBDA(val, SUBTOTAL(103, val))) to each row in the range A3:A8.

Notes:

You can replace 103 in the formula with 3. Both represent COUNTA, but 103 skips all hidden rows, whereas 3 skips only rows hidden via filtering (e.g., using a Data Filter or Slicer).

The SUBTOTAL reference must be from the first row of the search column, i.e., the very first cell in the range.

Formula Example: VLOOKUP Skips Hidden Rows in Google Sheets

Example Data

  • Range: A3:C8 (excluding hedder row)
  • Search Key: Dominic (from the first column)
  • Index Column: 2 (Column B, the formula will return a value from this column).

The name “Dominic” is in cells A4 and A7. If row 4 is hidden, the following regular VLOOKUP formula would still return the value 600, which is in the hidden cell B4:

=VLOOKUP("Dominic", A3:C8, 2, 0)

Correct VLOOKUP Formula to Skip Hidden Rows

To skip hidden rows, use the following formula:

=ARRAYFORMULA(VLOOKUP("Dominic", IF(D3:D8=1, A3:C8), 2, 0))
Google Sheets table showing VLOOKUP skipping hidden rows

Explanation of the Formula

The helper column plays a vital role in the formula. Instead of directly using A3:C8 as the VLOOKUP range, the formula uses a logical IF statement referencing the helper column. Here’s the modified range:

IF(D3:D8=1, A3:C8)

This range excludes rows where D3:D8 equals 0 (hidden rows). To make this work across the entire range, you must wrap the formula in ArrayFormula:

=ARRAYFORMULA(IF(D3:D8=1, A3:C8))

Output:

Hidden rows in the VLOOKUP range converted to FALSE values

Visible rows in the lookup range remain intact, while hidden rows are replaced with FALSE values. This ensures the VLOOKUP search key does not match any hidden rows.

Additional Resources

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.

How to Extract Numbers from Text in Excel with Regex

You can use the REGEXEXTRACT or REGEXREPLACE functions to easily extract numbers from text...

Using OFFSET and MATCH Together in Google Sheets: Advanced Tips

One powerful and flexible way to look up values is by combining the OFFSET...

How to Use OFFSET and XMATCH Functions Together in Excel

We often use the OFFSET and XMATCH functions together to match a value in...

How to Calculate Maximum Drawdown in Excel and Google Sheets

You can use the following dynamic array formula to calculate maximum drawdown (MDD) in...

More like this

Using OFFSET and MATCH Together in Google Sheets: Advanced Tips

One powerful and flexible way to look up values is by combining the OFFSET...

Running Count with Structured References in Google Sheets

Running a count with structured references is achievable in Google Sheets tables using the...

Running Total with Structured Table References in Google Sheets

You can use two types of formulas to create a running total with structured...

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.