Math & trig function

RANDBETWEEN function

Returns a random whole number between two values you specify, inclusive.

Available in Excel 2007 and later (earlier with the Analysis ToolPak), Excel for the web, Excel for Mac

Excel 2007 and laterWorks in Google Sheets

Syntax

RANDBETWEEN(bottom, top)
ArgumentWhat it means
bottomRequiredThe smallest whole number that can be returned.
topRequiredThe largest whole number that can be returned.

Returns: A random integer from bottom to top (both included).

How RANDBETWEEN works

RANDBETWEEN picks a random whole number in a range, with both ends included: =RANDBETWEEN(1, 6) behaves like a die. It is the quickest way to create realistic test data (quantities, prices, scores), pick a random row for an audit, draw a winner or generate random dates, since dates are whole numbers in Excel.

The function is volatile, so every edit in the workbook or a press of F9 produces new numbers. Copy and Paste Special > Values when you want to keep them. Each cell is independent, so duplicates are possible; for a unique random order use SORTBY with RANDARRAY, or a RAND helper column and a sort.

Examples

1Roll a die

A1fx=RANDBETWEEN(1, 6)
A
14

Result: 4

Any whole number from 1 to 6 with equal probability. Because the function recalculates whenever the sheet changes, your result will differ; the value shown is only an illustration.

2Test data for daily sales

B2fx=RANDBETWEEN(500, 2000)
AB
1
21,377

Result: 1,377

Fill down to create a column of random sales between 500 and 2,000 for practising formulas and charts (number format #,##0). Because the function recalculates whenever the sheet changes, your result will differ; the value shown is only an illustration.

3Random date in 2026

C2fx=RANDBETWEEN(DATE(2026,1,1), DATE(2026,12,31))
ABC
1
22026-08-14

Result: 2026-08-14

Dates are serial numbers (46023 to 46387), so RANDBETWEEN returns one of them; format the cell as a date. Because the function recalculates whenever the sheet changes, your result will differ; the value shown is only an illustration.

4Draw a prize winner

C2fx=INDEX(A2:A6, RANDBETWEEN(1, ROWS(A2:A6)))
ABC
1Employee
2AnaBen
3Ben
4Chloe
5Dev
6Ema

Result: Ben

ROWS counts the 5 entries, RANDBETWEEN picks a position and INDEX returns the name. Because the function recalculates whenever the sheet changes, your result will differ; the value shown is only an illustration.

⬇Practice workbookExamples with live formulas + practice sheets · .xlsx · 17 KB

Common errors and how to fix them

ErrorWhy it happensFix
#NUM!bottom is greater than top.Swap the arguments.
#VALUE!An argument is text.Use numbers or dates.

Tips

  • Random decimals with 2 places: =RANDBETWEEN(1000, 5000)/100 gives 10.00–50.00.
  • Use Paste Values after drawing a winner so the result is documented.

Questions

How do I get random numbers without duplicates?

In Microsoft 365: =TAKE(SORTBY(SEQUENCE(49), RANDARRAY(49)), 6) draws 6 different numbers from 1–49. In older versions, add a RAND helper column and use RANK.EQ.

Why do my random numbers change when I type elsewhere?

RANDBETWEEN is volatile and recalculates on every change. Paste the results as values to freeze them.

Google Sheets

RANDBETWEEN also exists in Google Sheets and works the same way for everyday use, so the examples above work there too.

RANDBETWEEN in other languages

In a non-English version of Excel the function has a local name. Excel translates formulas automatically when a file is opened in another language.

LanguageFunction name
DanishSLUMPMELLEM
DutchASELECTTUSSEN
FinnishSATUNNAISLUKU.VÄLILTÄ
FrenchALEA.ENTRE.BORNES
GermanZUFALLSBEREICH
HungarianVÉLETLEN.KÖZÖTT
ItalianCASUALE.TRA
Norwegian (Bokmål)TILFELDIGMELLOM
PolishLOS.ZAKR
Portuguese (Brazil)ALEATÓRIOENTRE
Portuguese (Portugal)ALEATÓRIOENTRE
RussianСЛУЧМЕЖДУ
SpanishALEATORIO.ENTRE
SwedishSLUMP.MELLAN
TurkishRASTGELEARADA

Recipes that use RANDBETWEEN