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

- Randomness has many uses in science, art, statistics, cryptography, gaming, gambling, and other fields.
- 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.

### 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**

**#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).

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.

#### 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.

- Press
**Ctrl+C**to copy the values.

- Without changing the selection, Press
**Alt+Ctrl+V**to open the**‘Paste Special’**Dialog box.

- Choose
**‘Values’**from the options and click on ok.

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

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:

4.9 (1,353 ratings) 35+ Courses | 120+ Hours | Full Lifetime Access | Certificate of Completion

- First, type
**=rand()**in the formula bar, then press F9 and hit**‘Enter.’**

After pressing F9, we get the value only.

#### 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**‘

### 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:

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

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

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.

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.

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.

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

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.

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 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.

You can drag the same for the remaining cells.

### Random Numbers in Excel – Project 4 – Creating Ludo Dice

Using the RANDBETWEEN function, 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**

- Apply the border to the merged cell using the shortcut key (
**ALT+H+B+T**) by pressing one key after another.

- Center and middle align the value using
**Home**Tab->**Alignment**Group -> ‘**Center’**and ‘**Middle Align**‘ command.

- To create the button, use
**Developer**tab ->**Controls**Group ->**Insert**->**‘Command Button’**

- Create the button and choose
**‘View Code’**from the ‘**Control’**group on ‘**Developer.’**

- After choosing ‘
**CommandButton1**‘ from the drop-down, paste the following code:

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

Cells(2, 2) = RN

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.’**

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

### 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