To group numbers into "buckets", you can use the VLOOKUP function with a custom grouping table. This allows you to make completely custom or arbitrary groups. In the example shown, the formula in F7 is:


Where age_table is the named range G5:H8. As the formula is copied down, it returns the correct group for each age from the values in H5:H8.

Generic formula



In this example, the goal is to group ages into buckets. One way to do this is to prepare a table with age breakpoints in the first column, and the name of the appropriate group or bucket in the second column. Then use a lookup function to find the right bucket or group for each age. In the example shown, we are using the VLOOKUP function for this job, and the formula in cell F7, copied down, is:


The inputs to VLOOKUP are as follows:

  • lookup_value - the age from cell D5
  • lookup_table - "age_table", which is the named range G5:H8.
  • col_index_num - 2 to indicate "2nd column"
  • range_lookup - TRUE to specify an approximate match.

Note that because the last argument, range_lookup, is optional and defaults to TRUE, it is not necessary to provide a value for this problem. However, I personally like to set this value explicitly as a reminder of the match behavior that is expected. Also note that we are using a named range for convenience only, since named ranges do not change when copied. If you prefer, you can use an absolute reference like $G$5:$H$8 instead. We don't want this reference to change as the formula is copied down.

In the configuration above, VLOOKUP looks up each age in the table and returns the appropriate group from the second column. Because VLOOKUP is set to perform an approximate match, it has a particular behavior. It will scan through the ages and stop at the first exact match, or, when no exact match is found, it will stop at the first larger value and then "step back" to the previous row and return the group from that row. The groups in the second column can be any values you wish.

For more details on VLOOKUP, see How to use the VLOOKUP function.

The age table must be sorted in ascending order by age for this formula to work properly.

Pivot tables

Pivot tables can automatically group numbers, but the VLOOKUP approach allows you to perform completely custom grouping.

Dave Bruns Profile Picture

AuthorMicrosoft Most Valuable Professional Award

Dave Bruns

Hi - I'm Dave Bruns, and I run Exceljet with my wife, Lisa. Our goal is to help you work faster in Excel. We create short videos, and clear examples of formulas, functions, pivot tables, conditional formatting, and charts.