Random Formula: The Easiest Way to Generate One

Formulas & functions · Updated November 23, 2026

If you need a random formula, the simplest one is =RAND() in Excel or Google Sheets, which returns a decimal between 0 and 1. For a random integer between two numbers, use =RANDBETWEEN(bottom, top), for example =RANDBETWEEN(1, 100) gives a whole number from 1 to 100.

What Does a Random Formula Actually Do?

A random formula is a spreadsheet function that generates a number or value that appears unpredictable. In Excel, the two core functions are RAND() and RANDBETWEEN(). RAND() takes no arguments and outputs a decimal between 0 and 1 (inclusive of 0, exclusive of 1). RANDBETWEEN(bottom, top) outputs a whole number between the two specified integers, inclusive. Both are volatile functions, meaning they recalculate every time the worksheet recalculates—like when you press F9 or enter new data anywhere. This is useful for simulations, random sampling, or assigning random values, but it also means the value changes constantly unless you copy and paste as values.

How to Use RAND and RANDBETWEEN in Excel

In Microsoft 365 Excel (Windows or Mac), type =RAND() in any cell and press Enter. You’ll see a decimal like 0.732. To get a random integer, type =RANDBETWEEN(1, 10) to get a number between 1 and 10. If you need a random percentage, multiply RAND by 100: =RAND()*100. For a random number with a specific number of decimal places, use =ROUND(RAND()*100, 2). To generate a random date between two dates, use =RANDBETWEEN(DATE(2023,1,1), DATE(2023,12,31)) and format the cell as a date. On Mac, the functions work identically; the only difference is that pressing F9 (Windows) to recalc is replaced by Cmd+= on Mac, but the formula itself is the same.

How to Choose the Right Random Formula

Choosing depends on what kind of randomness you need:

  • Decimal between 0 and 1: Use =RAND().
  • Integer between two numbers: Use =RANDBETWEEN(bottom, top).
  • Decimal within a range: Use =RAND()*(max-min)+min, e.g., =RAND()*10+5 gives a number between 5 and 15.
  • Random item from a list: Use =INDEX(list_range, RANDBETWEEN(1, COUNTA(list_range))). For example, with names in A2:A10, =INDEX(A2:A10, RANDBETWEEN(1, COUNTA(A2:A10))).
  • Random TRUE/FALSE: Use =RANDBETWEEN(0,1)=1 or =RAND()>0.5.

For a random sample without repeats, you’d need a more complex array formula, but for most everyday uses, the above cover it.

Common Problems and Fixes

One common issue: the random number changes every time you edit any cell. That’s by design, but if you want to keep a fixed value, copy the cell and use Paste Special > Values (right-click > Paste Special > Values). Another problem: RANDBETWEEN returns an error if the bottom is greater than the top. Also, if you use RAND() in a large dataset, recalculations can slow down your workbook. To avoid this, set calculation to manual (Formulas > Calculation Options > Manual) and press F9 when you want new numbers. If you need a random decimal with a specific number of digits, =ROUND(RAND(), 2) works. If you get a #NAME? error, check that you spelled the function correctly and that you’re not using a non-English locale where the function might be called ALEA or similar.

Random Formulas in Google Sheets vs. Excel

Google Sheets uses the same RAND() and RANDBETWEEN() functions, so the syntax is identical. However, Google Sheets recalculates less frequently—only when the sheet changes or you press Ctrl+R (Cmd+R on Mac) to force a refresh. Also, Google Sheets has an extra function, RANDARRAY(), which isn’t in Excel (though Excel 365 has a similar RANDARRAY function). In Excel for Microsoft 365, =RANDARRAY(5,1,1,100,TRUE) returns a 5×1 array of random integers between 1 and 100. In Google Sheets, you can use =RANDARRAY(5,1,1,100,TRUE) as well, but the function is available in both. The key difference is that in Excel, RANDARRAY is dynamic and spills; in Google Sheets, it also spills but you may need to press Ctrl+Shift+Enter in older versions. For most users, the basic RAND and RANDBETWEEN are enough.

Safety and Accuracy Tips for Random Data

Random formulas are safe in the sense that they don’t contain personal data, but they can cause problems if used incorrectly. For example, if you use a random formula in a cell that is referenced by other formulas, those references will change each recalculation, potentially breaking your model. Always consider whether you need a static value. Also, if you’re using random numbers for statistical sampling, be aware that RAND() and RANDBETWEEN() are pseudo-random—they’re generated by an algorithm, not truly random. For most purposes, that’s fine, but for scientific or cryptographic use, you’d need a dedicated tool. When generating random numbers for a lottery or game, make sure the range is correct and that you don’t accidentally include or exclude endpoints. For example, =RANDBETWEEN(1,6) simulates a die roll, but =RANDBETWEEN(0,1) gives 0 or 1, not 1 or 2. Always test your formula by pressing F9 a few times to see the range of results.

Alternatives to RAND and RANDBETWEEN

If you need more control, Excel 365 offers RANDARRAY() to generate a whole array of random numbers at once. For example, =RANDARRAY(10,1,1,100,TRUE) creates 10 rows of integers between 1 and 100. There’s also RAND() combined with NORM.INV() to generate normally distributed random numbers: =NORM.INV(RAND(), mean, standard_dev). For random text, you can combine RANDBETWEEN with CHAR() to get random letters: =CHAR(RANDBETWEEN(65,90)) gives a random uppercase letter. If you need a random sample without duplicates, you can use the SORTBY function with RANDARRAY: =SORTBY(A2:A10, RANDARRAY(ROWS(A2:A10))) shuffles the list. These are more advanced but useful for simulations.

Frequently Asked Questions

Why does my random number change every time I type something?
Because RAND and RANDBETWEEN are volatile functions—they recalculate whenever the worksheet recalculates. To freeze the value, copy the cell and paste as values (right-click > Paste Special > Values).

How do I get a random number between 1 and 100 that doesn’t change?
Use =RANDBETWEEN(1,100), then immediately copy the cell and paste as values. Or set calculation to manual (Formulas > Calculation Options > Manual) and only press F9 when you want a new number.

Can I generate a random date in Excel?
Yes, use =RANDBETWEEN(DATE(2020,1,1), DATE(2030,12,31)) and format the cell as a date. The result will be a random date within that range.

Is there a way to get a random name from a list?
Yes, if your list is in A2:A10, use =INDEX(A2:A10, RANDBETWEEN(1, COUNTA(A2:A10))). This picks a random row from the list. Make sure there are no blank cells in the list, or COUNTA will count them.

Are RAND and RANDBETWEEN truly random?
No, they are pseudo-random—they use an algorithm to generate numbers that appear random. For most everyday uses, this is sufficient, but for cryptography or scientific research, you should use a dedicated random number generator.

Related

Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.

More in Formulas & functions

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

Spotted an error in this guide? Let us know.