logo
search
Function Problems

How to Return Product Height Based on Selected Size in Excel

Elise WilliamsElise Williams Oct 9, 2026 870 views

Question details

The user needs an Excel formula to retrieve a product's height based on a selected size from a horizontally arranged dataset.

How to Return Product Height Based on Selected Size in Excel
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.
Before you start

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

Solution 1Recommended

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.

1
Select the destination cell

Click on cell B8 where you want the product height to be displayed.

2
Enter the XLOOKUP formula

Type =XLOOKUP(B4,'Data Sheet'!$B$2:$P$2,'Data Sheet'!$B$3:$P$3,"") into the formula bar and press Enter.

3
Test your formula

Change the selected product size in cell B4 to ensure the corresponding height in cell B8 updates automatically.

Use the XLOOKUP Function (Modern Excel Versions)
Why this works: XLOOKUP searches for the size in B4 within the size row ($B$2:$P$2) and returns the corresponding item from the height row ($B$3:$P$3). The empty quotes ("") ensure the cell remains blank if the size isn't found.
Free Spreadsheet Software

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. 1. Install WPS Office: Download and install WPS Office on your device.
  2. 2. Open your spreadsheet: Launch WPS Spreadsheet and open your existing workbook.
  3. 3. Enter the formula: Select cell B8 and input your preferred XLOOKUP or HLOOKUP formula.
  4. 4. Get the result: Press Enter to instantly get your corresponding product height.
Fully compatible with Microsoft Excel formulas and file formats (.xlsx).Supports advanced functions like XLOOKUP natively without extra setup.Free, lightweight, and features a familiar user interface.
microsoft office alternative - wps office

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.