Cellwise Start free

Excel guide · 7 min read

How to look up which range a number falls in

Quick answerList each band's lower limit in a column sorted smallest to largest, with the result beside it, and use =VLOOKUP(B4,$D$2:$F$5,3,TRUE), or =XLOOKUP(B4,$D$2:$D$5,$F$2:$F$5,,-1) in Excel 365 and 2021. Both return the row with the largest lower limit that is not above the number. If your bands are written as "up to" limits, look up the upper limits instead: =XLOOKUP(B3,$E$2:$E$5,$F$2:$F$5,"Outside area",1).

Sample data

Every result on this page was calculated from this sheet by the same spreadsheet engine the Cellwise app uses.

ABCDEFGHI
1OrderDistance (km)From (km)Up to (km)FeeZoneBand (as sent)
2D-30113.2054.5Local0-5
3D-301255157.9Zone 15-15
4D-301314.9153012.5Zone 215-30
5D-301427.4306019Regional30-60
6D-301560
7D-301685
8D-301712
9D-301841.5

Download this sheet as an Excel practice file (.xlsx)

Lower limits with VLOOKUP TRUE (every version)

The sheet is a courier's delivery log with a price list on the right: up to 5 km is Local, over 5 up to 15 km is Zone 1, and so on to 60 km. The fees in column F are example inputs; type the ones from your own price list. Keeping them in cells means a price change is one edit, not a hunt through formulas.

You do not need a row for every possible distance. VLOOKUP with TRUE (approximate match) looks down the first column for the largest value that is less than or equal to the number. 14.9 km is not in the table, but 5 is the largest limit at or below it, so VLOOKUP returns that row's fee. The column must be sorted smallest to largest and should start at 0, or numbers below the first limit return #N/A.

TRUE is VLOOKUP's default, so =VLOOKUP(B4,$D$2:$F$5,3) gives the same 7.90. With FALSE it looks for exactly 14.9 and returns #N/A. INDEX and MATCH work the same way with MATCH's last argument set to 1: =INDEX($F$2:$F$5,MATCH(B4,$D$2:$D$5,1)).

=VLOOKUP(B4,$D$2:$F$5,3,TRUE)

Result: 7.9

7.90: 14.9 km falls in the band that starts at 5 km (Zone 1).

XLOOKUP with match mode -1 (Excel 365 and 2021)

XLOOKUP's fifth argument, match_mode, set to -1 means "exact match, or else the next smaller item". That is the same lower-limit logic, with three improvements: the table does not have to be sorted, you point at the result column directly instead of counting columns, and an inserted column does not break it.

Point the return range at more than one column to get several results at once: =XLOOKUP(B9,$D$2:$D$5,$F$2:$G$5,,-1) spills 19 and Regional into two cells.

=XLOOKUP(B5,$D$2:$D$5,$G$2:$G$5,,-1)

Result: Zone 2

Zone 2: 27.4 km is at least 15 and below 30.

The boundary: is exactly 5 km Local or Zone 1?

Order D-3012 is exactly 5 km. A lower-limit lookup treats every From value as the start of its band, so 5 km lands in Zone 1 and costs 7.90. But the price list says "up to 5 km" is Local, at 4.50. Both formulas above are wrong for this one row, with no error to warn you.

Match the formula to how the bands are written. If the list says "from X", look up lower limits with -1 (or VLOOKUP TRUE). If it says "up to X", look up the upper limits with match mode 1, "exact match, or else the next larger item": 5 matches the 5 km row exactly and returns Local's fee. The if_not_found argument handles distances above the last limit.

Excel 2019 and earlier have no XLOOKUP, and MATCH's "next larger" mode (-1) needs the list sorted largest to smallest, so with VLOOKUP keep lower limits and decide on purpose which side a boundary belongs to. Test a value exactly on each limit before you trust the table.

=XLOOKUP(B3,$E$2:$E$5,$F$2:$F$5,"Outside area",1)

Result: 4.5

4.50: exactly 5 km is in the "up to 5 km" band. The lower-limit lookups return 7.90 for the same row.

Numbers above the top band

D-3016 is 85 km, outside the delivery area. A lower-limit lookup has no upper end: 85 is above 30, the last limit, so VLOOKUP and XLOOKUP with -1 both return the Regional fee of 19.00 as if the order were deliverable. This is the most expensive mistake with band tables, because the answer looks normal.

Check the top limit yourself: =IF(B7>MAX($E$2:$E$5),"Outside area",VLOOKUP(B7,$D$2:$F$5,3,TRUE)) returns Outside area, and gives the normal fee for every distance up to 60. With the upper-limit XLOOKUP from the previous section, the if_not_found text does the same job with no IF.

At the other end, a number below the first limit returns #N/A. If a negative or missing value is possible, that #N/A is useful: it tells you the input is wrong. Do not hide it with IFERROR.

=VLOOKUP(B7,$D$2:$F$5,3,TRUE)

Result: 19

19, which is wrong: 85 km is beyond the last band, but VLOOKUP charges the Regional fee.

Both limits at once with FILTER (gaps or unsorted bands)

When a table has gaps between bands, or rows in no particular order, test both limits in one go. Each comparison returns TRUE or FALSE for every band; multiplying them keeps only the band where both are true, and FILTER returns its fee. The test mirrors the price list: greater than From, and at most Up to.

If two bands overlap by mistake, FILTER returns both fees and spills them into two cells. That is a useful warning, not a bug. In Excel 2019 and earlier, =SUMPRODUCT((B9>$D$2:$D$5)*(B9<=$E$2:$E$5)*$F$2:$F$5) gives the same 19 for one matching band, but it returns 0 when nothing matches and adds the fees together if bands overlap, so check the table first.

=FILTER($F$2:$F$5,(B9>$D$2:$D$5)*(B9<=$E$2:$E$5),"Outside area")

Result: 19

19: 41.5 km is over 30 and up to 60. For the 85 km order the same formula returns Outside area.

Bands typed as text, and numbers stored as text

Price lists pasted from a PDF or email often have bands as text in one cell, like "5-15" in column I. No lookup can compare a number with "5-15". Split the limits out: =--TEXTAFTER(I3,"-") returns 15 as a number, and TEXTBEFORE gives the lower limit. You can do it inside the lookup, as below, or in helper columns, which are easier to check. TEXTAFTER and TEXTBEFORE need Excel 365 or 2024; in older versions use Data > Text to Columns with - as the delimiter.

The other side fails too. D-3017's 12 km came in as text, so every lookup on B8 returns #N/A even though 12 is clearly inside Zone 1. Convert it in the formula, =XLOOKUP(--B8,$E$2:$E$5,$F$2:$F$5,"Outside area",1) returns 7.90, or convert the column once.

Counts per band have the same weak spot. =COUNTIFS($B$2:$B$9,">"&D3,$B$2:$B$9,"<="&E3) counts Zone 1 orders and returns 1, not 2, because the text 12 is skipped without any error.

=XLOOKUP(B3,--TEXTAFTER($I$2:$I$5,"-"),$F$2:$F$5,"Outside area",1)

Result: 4.5

4.50 for the 5 km order, read straight from the text bands "0-5", "5-15" and so on.

Which method to pick

For "from X" bands in any version, VLOOKUP TRUE on sorted lower limits, wrapped in a top-limit check if values can go past the last band. In Excel 365 or 2021, XLOOKUP: -1 on lower limits for "from" bands, 1 on upper limits for "up to" bands, with if_not_found for anything outside. Use FILTER when bands have gaps or are unsorted. For many bands, any of these beats a nested IF, because the limits stay in cells you can see and change.

The same layout works for any published table: postage by weight, age bands, price breaks, or a rate schedule. Copy the published limits and rates into the input cells exactly as published. Finding the band a figure falls in is not the same as calculating an amount across several bands, where each slice gets its own rate; for that, see the tiered commission guide.

Common mistakes

An unsorted limit column with VLOOKUP TRUE

Approximate match assumes ascending order and returns wrong rows with no error otherwise. Sort the limits smallest to largest, or use XLOOKUP, which does not need sorting.

Using FALSE because "approximate" sounds risky

With FALSE, VLOOKUP only finds numbers typed exactly in the table and returns #N/A for 14.9. Band lookups need TRUE (or XLOOKUP match mode -1 or 1).

Values above the last band get the top band's result

A lower-limit lookup has no upper end. Check against MAX of the upper limits, or look up upper limits with XLOOKUP match mode 1 and an if_not_found message.

Boundary values in the wrong band

Lower-limit lookups put exactly 5 into the band that starts at 5. If your list says "up to 5", look up the upper limits instead. Test one value on each limit.

FAQ

How do I look up a value between two numbers in Excel?

Put the lower limit of each range in a sorted column and use =VLOOKUP(value,table,col,TRUE) or =XLOOKUP(value,lower_limits,results,,-1). To check both limits, use =FILTER(results,(value>=lower)*(value<=upper)).

Can VLOOKUP look up a range of numbers?

Yes, with TRUE as the last argument. It returns the row of the largest first-column value that is not above the lookup value, so each row stands for the range from its value up to the next row's value.

How do I return a value if a number falls within a range?

For one range use =IF(AND(B2>=low,B2<=high),result,""). For a table of ranges use VLOOKUP TRUE or XLOOKUP with match mode -1, which pick the right row without one IF per band.

How do I find which bracket a number falls in?

Type the bracket thresholds and rates from the official table into input cells, then use =XLOOKUP(value,thresholds,rates,,-1) to return the rate of the bracket the value reaches. Totals that apply a different rate to each slice need a separate slice-by-slice calculation.

What if my ranges are written like "10-20" in one cell?

Split them into numbers first, with TEXTBEFORE and TEXTAFTER on "-" or Data > Text to Columns. Lookups compare numbers, so a text range never matches.

Functions used

Related guides

Updated