Case-Sensitive Reverse VLOOKUP in Google Sheets

Published on

Case-sensitive Reverse VLOOKUP refers to looking up a search key in a column case-sensitively and returning the corresponding value from a column to the left. How can we do this in the example below? Is it a complex task?

DateItem CodeQty
21/09/2024PRT 500 AA100
22/09/2024PRT 500 Aa75
23/09/2024HRD 129 Y100
24/09/2024PRT 900 X150
25/09/2024HRD 129 y90

We can achieve this using VLOOKUP with EXACT or INDEX-MATCH with EXACT. In terms of complexity, it’s a relatively simple task.

In the following example, we will case-sensitively look up an item code in column B and return the corresponding date from column A. This can be called a case-sensitive reverse (leftward) lookup in Google Sheets.

In this example, PRT 500 AA and PRT 500 Aa are distinct, showing the case sensitivity of the lookup.

Example of Case-Sensitive Reverse VLOOKUP

The following formula in cell F2 will look up PRT 500 Aa entered in cell E2 in column B and return the date 22/09/2024 from column A.

=ArrayFormula(
   VLOOKUP(TRUE, HSTACK(EXACT(B2:B6, E2), A2:A6), 2, FALSE
   )
)
Example of Case-Sensitive Reverse VLOOKUP

Unlike in Excel, you can extend the ranges B2:B6 and A2:A6 to B2:B and A2:A, allowing the formula to include future values in these columns.

Let me explain this formula step-by-step. Then we will move on to case-sensitive reverse VLOOKUP using an alternative INDEX-MATCH method.

Formula Breakdown

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

Since VLOOKUP function can only search the first column of a range, for case-sensitive reverse VLOOKUP, we need to adjust the range accordingly.

  • Range: HSTACK(EXACT(B2:B6, E2), A2:A6) where:
    Virtual Range for Case-Sensitive Reverse VLOOKUP
    • EXACT(B2:B6, E2) checks if the text in E2 exactly matches each text in B2:B6, returning an array of TRUE or FALSE, with TRUE representing an exact match. This function needs ARRAYFORMULA to handle comparisons across a range.
    • HSTACK horizontally stacks the A2:A6 range alongside the array of TRUE/FALSE values, creating a two-column array for the lookup.
  • VLOOKUP(TRUE, …) searches for the first TRUE in the new virtual range and returns the corresponding value from the second column (the date).
  • The last argument FALSE ensures we are doing an exact match rather than a partial match, as the range is not sorted.

INDEX-MATCH Alternative for Case-Sensitive Reverse VLOOKUP

This is an alternative to the above VLOOKUP formula:

=INDEX(A2:A6, MATCH(TRUE, EXACT(B2:B6, E2), 0))

This method is quite straightforward if you’ve reviewed the case-sensitive VLOOKUP example above.

  • EXACT(B2:B6, E2) returns an array of TRUE or FALSE, where TRUE represents an exact match.
  • The MATCH function finds the first occurrence of TRUE in this array and returns the relative position.
  • The INDEX function uses that position to retrieve the corresponding value from the date column.

Since INDEX operates as an array formula, the use of the ARRAYFORMULA function is not necessary for EXACT.

It’s that simple! Test both formulas and see which one you prefer. I recommend using INDEX-MATCH for case-sensitive reverse VLOOKUP due to its simplicity.

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.

Lookup Values Under Categories in Excel and Google Sheets

We can use a combination of XLOOKUP and VLOOKUP in both Excel and Google...

Extract Items Under a Category from the Same Column in Excel

In Excel, you can use a combination of the XLOOKUP and DROP functions to...

How to Create a Searchable Table in Excel Using the FILTER Function

Finding specific records, or rows containing the required information, is straightforward in Excel using...

Time Sequences in Excel by Minute, Hour, or Second Increments

Creating time sequences, whether by hour, minute, or second increments in Excel, can be...

More like this

XMATCH Row by Row: Finding Values Across a Range in Google Sheets

Using the BYROW function with XMATCH in Google Sheets allows us to match values...

Limit Formula Expansion to a Specific Row in Google Sheets

In this tutorial, I’ll explain how to limit the expansion of an array formula...

3-D Referencing Structured Data Tables in Google Sheets

When you have several tables within a single sheet—not across multiple sheets in a...

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.