Summary

To generate a random number between two numbers, you can use the RANDBETWEEN function. In the example shown, the formula in B5 is:

=RANDBETWEEN(1,100)

As the formula is copied down, it returns a random integer between 1 and 100.

Generic formula

=RANDBETWEEN(lower,upper)

Explanation

The Excel RANDBETWEEN function returns a random integer between given numbers. In the example shown, the formula in B5 is:

=RANDBETWEEN(1,100)

This formula is then copied down from B5 to B11. The result is random numbers between 1-100.

RANDBETWEEN is a volatile function that recalculates when a worksheet is opened or changed. This includes any edits to the worksheet, or simply opening the workbook. To prevent random numbers from being recalculated again, you can replace the formulas with the values last calculated:

  1. Select the random numbers
  2. Copy the formulas to the clipboard with Control + C.
  3. Open the Paste Special Window and select "Values"
  4. Click OK to replace the formulas with static values.

For random results that only change when you change a seed value, see Seeded Random Number Generator in Excel (Excel 365), which also shows how to scale random numbers to a range.

Notes

  1. The RAND function can generate random decimal values.
  2. The RANDARRAY function (available in Excel 2021+ and Excel 365) can generate random numeric arrays.

Video: How to pick names out of a hat with Excel (3 min, free). It's one of 117 lessons in our Core Formula course.

Support Exceljet

Many websites (including Exceljet) have lost over half their traffic in the past year because of the crushing impact of AI on web searches. Exceljet is still at it, publishing free content each week. If you find Exceljet helpful, you can support the site and go ad-free with the Exceljet Lifetime Pass. One payment, no subscription, and ads are gone forever. Plus, you get our Excel Shortcuts video course as a thank you.

Get the Lifetime Pass

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.