Random Numbers in Excel

Random numbers in excel are used when we want to randomize our data for a sample evaluation, these numbers generated are absolutely random, there are two inbuilt functions in excel which gives us random values in cells, =RAND() function gives us any value from range 0 to 1 whereas another random function =RANDBETWEEN() takes input from user for a random number range.

Generate Random Numbers in Excel

  1. Randomness has many uses in science, art, statistics, cryptography, gaming, gambling, and other fields.
  2. Generating Random numbers in excel is important because many things in real life are so complicated that they appear random. Therefore, to simulate those processes, we need random numbers.

Many randomizing devices such as dice, shuffling playing cards, and roulette wheels seem to have been developed for use in games of chance. However, these cannot be used for digitized files. That is why we need to have tools for generating random numbers in excel.

You are free to use this image on your website, templates etc, Please provide us with an attribution linkHow to Provide Attribution?Article Link to be Hyperlinked
For eg:
Source: Random Numbers in Excel (wallstreetmojo.com)

How to Generate Random Numbers in Excel?

There is a number of methods to generate a random number in excel. We will discuss the two of them – Rand() and Randbetween() Functions

You can download this Generate Random Number Excel Template here – Generate Random Number Excel Template

#1 – RAND() Function

To generate a random number in excel between 0 and 1(excluding), we have RAND() function in Excel.

RAND() functions return a random decimal number that is equal to or greater than 0 but less than 1 (0 ≤ random number <1). RAND recalculates when a worksheet is opened or changed (Volatile Function).

RAND function returning the value between 0 and 1 (excluding).

random numbers

We just need to type ‘=RAND()‘ in the cell and press Enter. The value will change every time when any change is made in the sheet.

How to Generate Random Numbers in Excel for more than One Cell?

If we want to generate random numbers in excel for more than one cell, then we need

  • First, make a selection of the required range, then type =’rand()‘ And pressing ‘Ctrl+Enter’ will give us the values.
random numbers 1

How to Stop Recalculation of Random Numbers in Excel?

As RAND function recalculates, if any change in the sheet is made, we need to copy and then paste the formulas as values if we do not want values to be changed every time. For this, we need to paste the values of the RAND() function using Paste Special so that it would no longer be a result of the ‘RAND ()’ function and will not recalculate.

To do this,

  • We need to make the selection of the values.
random numbers 2
  • Press Ctrl+C to copy the values.
random numbers 3
  • Without changing the selection, Press Alt+Ctrl+V to open the ‘Paste Special’ Dialog box.
random numbers 4
  • Choose ‘Values’ from the options and click on ok.
random numbers 6

Now we can see, the value in the formula bar is the value itself, not the rand() function. Now, these are only values.

random numbers 5

There is one more way to get the value, only not the function as a result, but that is only for one cell. If we want the value at the very first time, not the function, then the steps are:

  • First, type =rand() in the formula bar, then press F9 and hit ‘Enter.’
random numbers 7

After pressing F9, we get the value only.

random numbers 8

Value from a Different Range other than 0 and 1 using RAND()

As RAND function returns a random decimal number between 0 and 1 only, if we want the value from a different range, then we can use the following function:

Let ‘a’ be the start point.

And ‘b’ be the endpoint

The function would be ‘RAND()*(b-a)+a’

For example, we suppose 7 as ‘a’ and 10 as ‘b’, then the formula would be ‘=RAND()*(10-7)+7

random numbers 9

RANDBETWEEN() Function

As the name of the function indicates, this function returns a random integer between given integers. Like RAND() function, this function also recalculates when a workbook is changed or opened (Volatile Function).

The formula of the RANDBETWEEN Function is:

RANDBETWEEN Formula

Bottom: An integer representing the lower value of the range.

Top: An integer representing the lower value of the range.

random numbers 10

To generate random numbers in excel for the students between 0 and 100, we will use the ‘RANDBETWEEN’ function.

First, we need to select the data, then type the formula, i.e., =RANDBETWEEN(0,100), and hit Cntrl + Enter. You can prefer the below-given screenshot.

random numbers 11

As values will recalculate, we can use Alt+Ctrl+V to open the ‘Paste Special’ Dialog box to paste as Values only.

Follow the steps given below in the screenshot.

random numbers 12

Like RAND() function, we can also use the method of typing the RANDBETWEEN function in the formula bar and pressing F9 to convert the result into value, and then press Enter.

Things to Remember

  • If the bottom is greater than the top, the RANDBETWEEN function will return #NUM!
  • If either of the supplied arguments is non-numeric, the function will return #VALUE!
  • Both RAND() and RANDBETWEEN() function are a volatile function (recalculates), hence adds to the processing time and can slow down the workbook.

Random Numbers in Excel – Project 1

We can use the RANDBETWEEN() function for getting random dates between two dates.

We will be using 2 dates as the bottom and top arguments.

random numbers 13

We need to copy down the formula using the shortcut (Ctrl+D) after making the selection.

random numbers 14

We can change Start (D1) and End Date (E1) to change the top and bottom values for the function.

Random Numbers in Excel – Project 2 –  Head and Tail

To randomly choose head and tail, we can use the CHOOSE function in excel with the RANDBETWEEN function.

random numbers 16

We just need to copy the formula into the next and next cell every time in the game, and ‘Head’ and ‘Tail’ will come randomly.

random numbers 15

Random Numbers in Excel – Project 3 – Region Allocation

Many times, we have to imagine and create data for various examples. Suppose we have data for sales, and we need to allocate three different regions to every transaction of sale.

Then we could use the RANDBETWEEN function with the CHOOSE function.

random numbers 17

You can drag the same for the remaining cells.

random numbers 18

Random Numbers in Excel – Project 4 – Creating Ludo Dice

Using the RANDBETWEEN functionUsing The RANDBETWEEN FunctionRANDBETWEEN excel formula determine random numbers between two extreme variables (bottom and top numbers). The user needs to fill in the bottom and top numbers in the syntax =RANDBETWEEN (bottom, top) to acquire the random integer.read more, we can also create dice for Ludo. To do the same, we need to use the RANDBETWEEN function in Excel VBA. Please follow the below steps:

  • Merge the four cells (B2:C3) using Home Tab-> Alignment Group-> Merge & Center
random numbers 19
  • Apply the border to the merged cell using the shortcut key (ALT+H+B+T) by pressing one key after another.
random numbers 20
  • Center and middle align the value using Home Tab-> Alignment Group -> ‘Center’ and ‘Middle Align‘ command.
random numbers 21
random numbers 22
  • Create the button and choose ‘View Code’ from the ‘Control’ group on ‘Developer.’
random numbers 24
  • After choosing ‘CommandButton1‘ from the drop-down, paste the following code:

RN = (“=RANDBETWEEN(1,6)”)

Cells(2, 2) = RN

random numbers 23

Save the file using the .xlsm extension as we have used the VBA code in the workbook. After coming to the Excel window, deactivate the ‘Design Mode.’

random numbers 25

Now, whenever we click on the button, we get a random value between 1 and 6.

random numbers 26

Recommended Articles

This has been a guide to Random Numbers in Excel. Here we discuss how to generate random numbers in excel using RAND() and RANDBETWEEN function along with multiple projects and downloadable excel templates. You may also look at these useful functions in excel

  • 35+ Courses
  • 120+ Hours
  • Full Lifetime Access
  • Certificate of Completion
LEARN MORE >>