Generate Random Number in Excel: RAND, RANDBETWEEN & More

How-to basics · Updated November 23, 2026

Yes, you can generate random numbers in Excel using the RAND and RANDBETWEEN functions. RAND() returns a decimal between 0 and 1, while RANDBETWEEN(bottom, top) returns a whole number between two specified values. For example, =RANDBETWEEN(1,100) gives a random integer from 1 to 100. These functions recalculate every time the worksheet changes, so if you need a static list, you must copy and paste as values.

How RAND and RANDBETWEEN Work

RAND() takes no arguments and returns a decimal number greater than or equal to 0 and less than 1. It is a volatile function, meaning it recalculates whenever Excel recalculates the workbook (e.g., when you edit a cell or press F9). RANDBETWEEN(bottom, top) takes two numbers and returns an integer between them, inclusive. For instance, =RANDBETWEEN(10,20) can return 10, 20, or any integer in between.

Both functions are available in Excel for Microsoft 365, Excel 2021, Excel 2019, and earlier versions, as well as in Google Sheets. In Excel for the web, they work the same way, but recalculation happens when the browser refreshes or when you edit.

How to Generate a Random Number: Step by Step

  1. Click on the cell where you want the random number to appear.
  2. Type =RAND() for a decimal between 0 and 1, or =RANDBETWEEN(1,100) for a whole number between 1 and 100 (adjust the numbers as needed).
  3. Press Enter. The cell shows the random value.
  4. To freeze the value (so it doesn’t change), copy the cell, right-click the target cell, and choose Paste Special > Values (or press Ctrl+Alt+V, then V, then Enter on Windows; on Mac, use Ctrl+Command+V and select Values).

If you need a list of random numbers, enter the formula in the first cell, then drag the fill handle down to fill the range. Each cell will have its own random value.

How to Choose Between RAND and RANDBETWEEN

Use RAND() when you need a continuous uniform distribution, such as for probability simulations or generating a random percentage. Use RANDBETWEEN() when you need discrete integers, like lottery numbers, dice rolls, or selecting a random row index. For example, to pick a random item from a list in A1:A10, you could use =INDEX(A1:A10, RANDBETWEEN(1,10)).

If you need random numbers without repetition (e.g., for a raffle), RAND is better because it produces decimals that are almost certainly unique. You can then sort by that column to shuffle a list.

Common Problems and How to Fix Them

  • Numbers change every time I edit a cell: This is normal because RAND and RANDBETWEEN are volatile. To stop them, paste as values as described above.
  • I need the same random sequence for reproducibility: Use the RANDARRAY function with a seed? Actually, Excel doesn’t have a seed parameter. Instead, copy the random numbers as values, or use a deterministic pseudo-random formula like =MOD(ROW()*17+5,100) if you need a repeatable sequence.
  • RANDBETWEEN returns a #NUM! error: This happens if the bottom number is greater than the top. Check your arguments.
  • I want a random decimal between 1 and 10: Use =RAND()*9+1 to get a decimal between 1 and 10 (inclusive of 1, exclusive of 10). For inclusive of both, use =RAND()*10 and round as needed.

Advanced Random Number Techniques

For generating multiple random numbers at once, use RANDARRAY (available in Excel 365 and Excel 2021). For example, =RANDARRAY(5,1,1,100,TRUE) returns a 5-row by 1-column array of integers between 1 and 100. The syntax is RANDARRAY([rows], [columns], [min], [max], [integer]).

To generate random dates, combine RANDBETWEEN with the DATE function: =RANDBETWEEN(DATE(2020,1,1), DATE(2024,12,31)) returns a random date in that range. For random text from a list, use =INDEX(A1:A5, RANDBETWEEN(1,5)).

RAND vs. RANDBETWEEN vs. RANDARRAY: Comparison

Function Returns Arguments Volatile?
RAND() Decimal 0 to <1 None Yes
RANDBETWEEN(bottom, top) Integer between bottom and top inclusive Two numbers Yes
RANDARRAY(rows, cols, min, max, integer) Array of numbers Optional, but min/max needed for range Yes

All three are volatile, so they recalculate. RANDARRAY is the most flexible for filling a range with one formula.

Safety and Accuracy Tips

Random numbers in Excel are not cryptographically secure. If you need random numbers for passwords, encryption, or gambling, use a dedicated tool like a password manager or a programming language’s secure random library. Also, be aware that volatile functions can slow down large workbooks because they recalculate often. To minimize performance impact, limit their use or paste as values when the results are final.

When using random numbers for sampling, ensure your method is unbiased. For example, if you use RANDBETWEEN(1,100) to select a row, each row has an equal chance. But if you use RAND() and sort, that’s also fine. Always verify that your range is correct.

Frequently Asked Questions

How do I generate a random number that doesn’t change?

After generating the random number, copy the cell and use Paste Special > Values. This replaces the formula with the static number. Alternatively, you can use the keyboard shortcut Ctrl+C, then Ctrl+Alt+V, V, Enter (Windows) or Command+C, then Control+Command+V, V, Enter (Mac).

Can I generate a random number between two decimals?

Yes, use the formula =RAND()*(max-min)+min. For example, to get a decimal between 5.5 and 9.9, use =RAND()*(9.9-5.5)+5.5. This returns a value like 7.234, inclusive of 5.5 and exclusive of 9.9. For inclusive of both, you’d need a more complex formula.

Why does my random number keep changing?

Because RAND and RANDBETWEEN are volatile functions. They recalculate whenever Excel recalculates, which happens when you edit any cell, press F9, or open the workbook. To stop it, paste as values.

How do I generate random numbers in Google Sheets?

Google Sheets has the same functions: RAND() and RANDBETWEEN(). They work identically. The main difference is that they recalculate when the sheet changes, but you can also use the menu Data > Randomize range to shuffle existing data.

Is there a way to generate a random number without using a formula?

Yes, you can use the Analysis ToolPak add-in in Excel for Windows. Go to Data > Data Analysis > Random Number Generation. This produces a static set of random numbers in a range, and you can choose the distribution (uniform, normal, etc.). However, the ToolPak is not available by default in Excel for the web or Mac.

Can I generate a random number in Excel for Mac?

Yes, the functions are the same. The Paste Special shortcut differs: on Mac, use Command+Control+V to open Paste Special, then select Values. The RANDARRAY function is available in Excel for Microsoft 365 on Mac as well.

Related

Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.

More in How-to basics

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.