The range G6:L7 contains quantity-based discounts.

Column B contains random quantities used when testing the formula.

This problem can be easily solved with the XLOOKUP function or the HLOOKUP function.

HLOOKUP formula to solve the same problem

Both methods are explained below.

The syntax used for horizontal lookups is the same as for vertical lookups.

This is not required with named ranges because they automatically behave as absolute references.

HLOOKUP formula to solve the same problem

If an exact match is found, the corresponding discount in row 7 is returned.

When an exact match isnot found, the discount associated with thenext smallestquantity is returned.

HLOOKUP formula

Working with HLOOKUP is similar to working with theVLOOKUP function.

HLOOKUP formula to solve the same problem

Both functions require theentire lookup tableas thetable_arrayargument and use an index number to specify return values.

This problem can also be solved with theHLOOKUP functionlike this:

Wheredatais the named range G6:L7.

Download the workbook and try it out yourself.

HLOOKUP formula to solve the same problem

XLOOKUP supports approximate and exact matching, wildcards (* ?)

HLOOKUP supports approximate and exact matching, and…

HLOOKUP formula to solve the same problem

Excel formula: XLOOKUP with multiple criteria

Excel formula: XLOOKUP with logical criteria

Excel formula: XLOOKUP lookup left

Excel formula: XLOOKUP basic exact match

Excel formula: XLOOKUP basic approximate match

Excel XLOOKUP function

Excel HLOOKUP function

HLOOKUP formula to solve the same problem