Vlookup and Hlookup Combination In Google Sheets

Published on

The Vlookup and Hlookup combination can do wonder in Google Sheets. I have seen users using a helper row to get this Vlookup and Hlookup Combination in Google Sheets to work. But I can show you how to use this combination without any helper row or column in Google Sheets.

Clueless, right?

I am talking about two-dimensional lookup in Google Sheets. In this lookup, the Vlookup will do the search across the first column for the provided key and the hlookup will do the search across the first row for another key. Then the formula would return the intersection value.

First, let me clarify the concept about the use of Vlookup and Hlookup together. See how a Vlookup and Hlookup combination in Google Sheets work.

You May Like: Lookup, Vlookup, and Hlookup Differences in Google Sheets

The Purpose of Vlookup and Hlookup Combination In Google Sheets

example to two-way lookup in Google Sheets

In this example, I have the employee names in Column A and their monthly allowances in other Columns.

I want to find the monthly allowance of a particular employee in a particular month.

Two-way Lookup in Google Sheets Using the Vlookup and Hlookup Combination

First I will explain to you how to do that. Hope you may already know the use of Vlookup.

Formula 1

=VLOOKUP(J2,A2:G6,4,0)

Formula 2

=VLOOKUP("Tina Hill",A2:G6,4,0)

You can use any of the above Vlookup formulas to find the allowance of the employee “Tina Hill” in “Mar”.

In these formulas, the #4 is the column index number of “Mar”.

Unlike Data Base functions like DSUM, we can’t use a field label corresponding to the column name to represent the column. I mean you can’t use “Mar” instead of 4 in Vlookup.

two-way lookup to return intersection value

Instead of the column Index 4, we can use an Hlookup inside Vlookup to search and return the column index number corresponding to “Mar”.

Vlookup Syntax:

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

Vlookup and Hlookup Combination Formula Syntax:

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

Here is that two-way lookup formula (Vlookup and Hlookup combination formula)

=ArrayFormula(VLOOKUP(J2,A1:G6,hlookup(J3,{A1:G1;column(A1:G1)},2,0),0))

The Hlookup in this formula returns the column Index based on the column name/field label in J3.

Currently, it returns 4 as the field label in J3 is “Mar” which is in the fourth column.

You May Like: Column Heading | Column Label | Column Name | Field | Field Label

Below I am explaining the Hlookup part of the formula.

Hlookup Syntax:

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

In my above Hlookup formula, the search key is the “Mar” in cell J3. The range is as below.

{A1:G1;column(A1:G1)}

To test this “range” just use it with the ArrayFormula as below.

=ArrayFormula({A1:G1;column(A1:G1)})

Here is the result. It has the field labels in the first row as it is and the second row contains the column numbers. The function Column returns these numbers.

The role of Hlookup in index column in Vlookup

The above Hlookup formula searches across the first row for the key “Mar” in this range and returns the value from the second row, i.e. 4.

See the column Index in Hlookup, i.e. 2 (second row).

This way you can use the Vlookup and Hlookup Combination in Google Sheets.

Two-Way Lookup in Google Sheets – Using Vlookup and Match

Here is an easier solution to the above using Vlookup and Match.

=ArrayFormula(VLOOKUP(J2,A1:G6,MATCH(J3,A1:G1,0),0))

Actually, this tutorial is about the combined use of Vlookup and Hlookup in Google Sheets. Still, I am introducing you to this new combo as this is easy to understand and use.

Here the MATCH just replaces the Hlookup. The match function searches across the first row for the key in J3 and returns the relative position of the key.

Two-Way Lookup Additional Tip

The formula that I am going to provide you below won’t work in all cases.

If your column labels are the month names as above, there is a shorter solution using the Date function. Here is that formula.

=ArrayFormula(VLOOKUP(J2,A1:G6,month(J3&1),0))

Here the Index number is replaced by the Month function. This formula is only applicable to the columns that contain the month names as column names/field labels.

Alternative to the combination of Vlookup and Hlookup

How this Month function returns the column index? Actually, it returns the month number from month name.

Must Read: Formula to Convert Month Name in Text to Month Number in Google Sheets

You have now three different formulas to do a two-way lookup in Google Sheets.

Hope you have enjoyed the stay!

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...

4 COMMENTS

  1. Hi,

    I’m trying to combine multiple conditions in an hlookup with a Vlookup.

    I have two rows that I need to pull different values from (hence multiple conditions with an hlookup), but I also want to Vlookup for a specific date.

    I’m getting the right results without adding the Vlookup into the formula, but once I add the Vlookup, I get an error that says “Vlookup evaluates to an out of bound range.”

    Can you help take a look at my formula in cell F3 to see what’s incorrect? Thank you!

    • Hi, Jeannie,

      This is your existing formula on the Sheet.

      =arrayformula(vlookup(E3,A:C,HLOOKUP("emailOrder Count",{$A$1:$C$1&$A$2:$C$2;$A3:$C3},2,0),0))

      See my new formula.

      =ArrayFormula(IFERROR(vlookup(E3:E,A3:C8,match("emailOrder Count",$A$1:$C$1&$A$2:$C$2,0),0)))

      You can easily find the difference. Also, see the image. I have keyed in this formula in cell F3 only.

      Array Use of Vlookup and Match combination

      • Hi Prashanth, thanks so much for the prompt response! Could you elaborate why match worked better in this case instead of hlookups?

        • Hi, Jeannie Wu,

          You want Vlookup to vertical lookup MULTIPLE SEARCH KEYS (E3:E), right?

          To do that, in Vlookup, you must find the Index column number dynamically. For this, you can either use the MATCH function or Hlookup.

          Match to return dynamic Index column:

          =ArrayFormula(match("emailOrder Count",$A$1:$C$1&$A$2:$C$2,0))

          Hlookup equivalent for returning dynamic index column:

          =ArrayFormula(hlookup("emailOrder Count",{($A$1:$C$1&$A$2:$C$2);column(A1:C1)},2,0))

          You have used this Hlookup formula wrongly earlier. That was the issue.

          Here are the formulas.

          Final Formula: Vlookup + Match:

          =ArrayFormula(IFERROR(vlookup(E3:E,A3:C8,match("emailOrder Count",$A$1:$C$1&$A$2:$C$2,0),0)))

          Note: In my earlier reply $A$1:$C$1&$A$2:$C$2 was wrongly entered as $B$1:$C$1&$A$2:$C$2 even though that was working for the current search key “emailOrder Count”. I have just updated my earlier comment to incorporate that correction.

          Equivalent Final Formula: Vlookup + Hlookup:

          =ArrayFormula(IFERROR(vlookup(E3:E,A3:C8,hlookup("emailOrder Count",{($A$1:$C$1&$A$2:$C$2);column(A1:C1)},2,0),0)))

          Hope this helps.

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.