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.

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.