No, you cannot nest an HLOOKUP inside a VLOOKUP to make a single formula that searches both horizontally and vertically at once. However, you can combine them by using an HLOOKUP result as the column index number inside a VLOOKUP, or by using INDEX and MATCH for a true two-way lookup. This article explains exactly how to do that, when it makes sense, and why most users are better off with INDEX/MATCH or XLOOKUP.
What HLOOKUP and VLOOKUP Actually Do
VLOOKUP searches for a value in the first column of a table and returns a value from a column you specify to the right. HLOOKUP does the same thing but sideways: it searches for a value in the first row and returns a value from a row you specify below. Both are lookup/reference functions in Excel, and both have been around for decades.
The key difference is the direction of the search. VLOOKUP works vertically (top to bottom), HLOOKUP works horizontally (left to right). That is why you cannot simply put one inside the other to get a two-way lookup—each function is designed for one dimension only.
How to Combine HLOOKUP and VLOOKUP in One Formula
You can make a two-way lookup by using an HLOOKUP to find the column number and feeding that number into VLOOKUP as the col_index_num argument. Here is a concrete example.
Assume you have a table with product names in column A (rows 2 to 10) and monthly sales data in columns B through M (January to December). The months are in row 1, B1:M1. You want to find the sales for a product in cell E15 and a month in cell E16.
With the product name in E15 and the month name in E16, the formula would be:
=VLOOKUP(E15, A2:M10, HLOOKUP(E16, B1:M1, 1, FALSE)+1, FALSE)
How it works: The inner HLOOKUP searches for the month in row 1 and returns the position of that month within B1:M1. For example, if the month is March, HLOOKUP returns 3 because March is the third cell in that range. Then you add 1 because column A is column 1, so March data is in column 4 (A=1, B=2, C=3, D=4). That number becomes the column index for VLOOKUP.
If the month is not found, HLOOKUP returns #N/A, and the whole formula returns #N/A. If the product is not found, VLOOKUP returns #N/A. This combination works, but it is fragile because the HLOOKUP range must exactly match the VLOOKUP table’s columns, and the +1 adjustment is easy to get wrong.
Why You Should Probably Use INDEX and MATCH Instead
For a true two-way lookup (find a value at the intersection of a specific row and a specific column), INDEX and MATCH is the standard, more robust approach. The formula is:
=INDEX(B2:M10, MATCH(E15, A2:A10, 0), MATCH(E16, B1:M1, 0))
Here, the first MATCH finds the row number of the product in column A, the second MATCH finds the column number of the month in row 1, and INDEX returns the value at that row and column. This is simpler, does not require the +1 adjustment, and works even if you insert or delete columns within the table (as long as the ranges adjust).
If you are using Excel 365 or Excel 2021, XLOOKUP can do the same job with a single function:
=XLOOKUP(E15, A2:A10, XLOOKUP(E16, B1:M1, B2:M10))
The inner XLOOKUP returns the entire row for the month, and the outer XLOOKUP finds the product in that row. This is the cleanest solution in modern Excel.
When Combining HLOOKUP and VLOOKUP Makes Sense
There are a few rare scenarios where the combination might be acceptable:
- You are forced to use a legacy file that already has HLOOKUP and VLOOKUP, and you cannot change the structure.
- You are teaching someone how the functions work, and you want to demonstrate nesting.
- You have a very small, fixed table and you are confident the column order will never change.
In all other cases, INDEX/MATCH or XLOOKUP is better because it is less error-prone, easier to read, and handles column insertions better.
Common Problems with the HLOOKUP+VLOOKUP Combo
The most frequent issue is the column index offset. Forgetting to add 1 (or adding it when not needed) returns the wrong column. Another issue is that HLOOKUP with FALSE requires an exact match, so if your month names have extra spaces or are formatted as dates, the lookup fails. Also, if your table has merged cells in the header row, HLOOKUP may return unexpected results because merged cells only hold a value in the top-left cell.
Finally, both functions are case-insensitive, which is usually fine, but if you need case-sensitive matching, you would need INDEX/MATCH with EXACT or XLOOKUP with a match mode.
How to Choose the Right Lookup Function
Here is a quick guide:
- If you need a simple vertical lookup with a fixed column number, use VLOOKUP.
- If you need a simple horizontal lookup with a fixed row number, use HLOOKUP.
- If you need a two-way lookup (row and column), use INDEX/MATCH or XLOOKUP.
- If you need to return multiple values, use XLOOKUP with a return array, or FILTER.
- If you need to look to the left of the lookup column, VLOOKUP cannot do it—use INDEX/MATCH or XLOOKUP.
In general, for any new work, XLOOKUP is the recommended function because it replaces both VLOOKUP and HLOOKUP and adds more features like error handling and reverse search.
Frequently Asked Questions
Can I use HLOOKUP inside VLOOKUP to search both rows and columns? Yes, you can nest them as shown above, but it is not a true two-way lookup in the sense of a single function. It works, but the column index adjustment is error-prone, and INDEX/MATCH is cleaner.
Why does my combined formula return #N/A? The most common causes are: the HLOOKUP cannot find the month (exact match required), the VLOOKUP cannot find the product, or the column index number is out of range (e.g., it exceeds the number of columns in the table). Check the ranges and the +1 offset.
Is there a function that does both HLOOKUP and VLOOKUP at once? Yes, XLOOKUP can handle two-way lookups when nested, and INDEX/MATCH can do it with two MATCH functions. There is no single built-in function named “HLOOKUPVLOOKUP,” but these combinations achieve the result.
Does HLOOKUP work in Google Sheets? Yes, HLOOKUP and VLOOKUP exist in Google Sheets with similar syntax. However, XLOOKUP is not available in Google Sheets (as of 2025), so you would use INDEX/MATCH for two-way lookups there.
What is the difference between HLOOKUP and VLOOKUP in terms of performance? Both are fast for small tables, but for very large datasets, INDEX/MATCH is often faster because it does not require the entire table to be scanned as VLOOKUP does. In modern Excel, performance differences are negligible for typical use.
Can I use HLOOKUP with wildcards? Yes, HLOOKUP supports wildcards (* and ?) when using approximate match (TRUE) or if you use the match mode in XLOOKUP. But with FALSE, wildcards are treated as literal characters.
Related
- Shortcut to Select Cell Range in Excel
- Shortcut to Switch Between Windows (All OS)
- Generate Random Number HTML: JS & Math.random Code
Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.
More in Formulas & functions
- Remove Spaces in Excel: The Shortcut and Right MethodTo remove every ordinary space from selected cells in Excel for Microsoft 365 on Windows, select the cells,…
- How to Extract One Word From a Cell in Excel With FormulasTo extract a particular word from text in Excel for Microsoft 365, put the text in A2 and…
- Excel Index Match Multiple Criteria Non Array?Yes, you can use INDEX and MATCH with multiple criteria in Excel without entering it as an array…
- Excel Concatenate Strings: The 4 Best WaysThe simplest way to concatenate (join) strings in Excel is to use the ampersand operator (&), like =A1&"…
- Excel Filter Dates by Month: Quick Steps and FixesTo filter dates by month in Excel, select a cell in your date column, choose Data > Filter,…
- Excel COUNTIF Range Examples: Text, Numbers, and DatesUse Excel’s COUNTIF function to count cells in a range that match one condition: for example, =COUNTIF(A2:A20,"East") counts…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.