How to Return Product Height Based on Selected Size in Excel
Question details
The user needs an Excel formula to retrieve a product's height based on a selected size from a horizontally arranged dataset.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Looking up a corresponding value from a horizontal dataset where product sizes are in one row and heights are in the row directly below.
- Observed behavior
- The formula needs to take the selected size in cell B4, search row 2 on the data sheet, and return the corresponding height from row 3 into cell B8.
Ensure your source dataset is organized with sizes in a single row (e.g., Row 2) and the corresponding heights in the row immediately below it (e.g., Row 3).
Use the XLOOKUP Function (Modern Excel Versions)
XLOOKUP is the most robust and flexible formula for horizontal and vertical lookups in modern versions of Excel.
If you are using Excel 2021 or Microsoft 365, XLOOKUP is the most efficient way to search for a value in one row and return a corresponding value from another row.
Click on cell B8 where you want the product height to be displayed.
Type =XLOOKUP(B4,'Data Sheet'!$B$2:$P$2,'Data Sheet'!$B$3:$P$3,"") into the formula bar and press Enter.
Change the selected product size in cell B4 to ensure the corresponding height in cell B8 updates automatically.

Use the HLOOKUP Function (Older Excel Versions)
If you are using an older version of Excel that does not support XLOOKUP, HLOOKUP combined with IFERROR is the best alternative.
Use WPS Spreadsheet for Advanced Formula Lookups
WPS Spreadsheet fully supports both XLOOKUP and HLOOKUP functions, making it incredibly easy to retrieve data from horizontal or vertical ranges. It is a completely free and fully compatible alternative for all your data processing needs.
- 1. Install WPS Office: Download and install WPS Office on your device.
- 2. Open your spreadsheet: Launch WPS Spreadsheet and open your existing workbook.
- 3. Enter the formula: Select cell B8 and input your preferred XLOOKUP or HLOOKUP formula.
- 4. Get the result: Press Enter to instantly get your corresponding product height.

Frequently Asked Questions
Why does my HLOOKUP formula return an #N/A error?
This usually happens when the lookup value (selected size) does not exactly match any value in the top row of your data range. Check for leading or trailing spaces in your cells, or wrap your formula in the IFERROR function to hide the error.
Can I use VLOOKUP instead of HLOOKUP for this scenario?
No, VLOOKUP is designed for vertical data where lookup values are located in columns. Since your product sizes are organized horizontally in a single row, you must use HLOOKUP or XLOOKUP.
Is XLOOKUP better than HLOOKUP?
Yes, XLOOKUP is more flexible and less prone to breaking if you insert or delete rows in your dataset. It can look both horizontally and vertically, and it features built-in error handling without needing an additional IFERROR wrapper.




