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.

Highlight Upcoming Birthdays in Google Sheets

When highlighting upcoming birthdays in Google Sheets, one important aspect is ignoring the year...

Compare Two Tables for Differences in Excel

To compare two tables with similar data for differences, you can use the XLOOKUP...

Calculate Weighted Average in Pivot Table in Google Sheets

You can calculate a weighted average in a Pivot Table using a custom formula...

Summarize Data and Keep the Last Record in Google Sheets

In Google Sheets, we can summarize data (like sum, average, min, max, count) using...

More like this

Highlight Upcoming Birthdays in Google Sheets

When highlighting upcoming birthdays in Google Sheets, one important aspect is ignoring the year...

Calculate Weighted Average in Pivot Table in Google Sheets

You can calculate a weighted average in a Pivot Table using a custom formula...

Summarize Data and Keep the Last Record in Google Sheets

In Google Sheets, we can summarize data (like sum, average, min, max, count) using...

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.