Not every user will have a need for random numbers in Excel. Most people work with fixed numbers and formulas and may have no need for random numbers to appear in their reports.

However, a random number generator does have a huge use when working with different scenarios on a set of data or when performing various statistical analyses.

A financial model may use a stochastic simulation that is dependent on probabilities. The model may need to be run thousands of times, but with the random number generator providing the parameters of each simulation.

Whatever your need for random numbers, Excel has several ways to generate them.

In this post, Iâll show you all the methods you can use to insert random numbers into your workbooks.

## Generate Random Numbers with the RAND function

The first way I will show you is the easiest way to generate random values in Excel.

There is a very simple **RAND** function that requires no parameters and will generate a random number between 0 and 1.

### Syntax for the RAND Function

`= RAND ( )`

This function has no required or optional arguments. The function is always entered with an empty set of parenthesis.

This function will generate a decimal random number between 0 and 1, but not including 0 or 1.

Repeated values are possible but unlikely since the **RAND** function produces numbers from a continuous range of numbers.

The values that are returned will follow a uniform distribution. This means that any number between 0 and 1 is equally likely to be returned.

### Generate Random Numbers Between Any Two Numbers

A decimal number between 0 and 1 may not be too useful if you need numbers between 1 and 10.

But you can use a simple formula involving the **RAND** function to generate random numbers between any two numbers.

`= RAND ( ) * ( Y - X ) + X`

In general, you can create a random number between X and Y by using the above formula.

`= RAND ( ) * 9 + 1`

For example, to generate numbers between 1 and 10 you can use the above formula.

This multiplies the random number generated by 9 and then adds 1 to it. This will produce decimal numbers between 1 and 10.

### Generate Random Integer Numbers Between Any Two Numbers

Another possible need you may encounter is to generate random whole numbers between two given numbers. This can also be done using a simple formula.

`= ROUND ( RAND ( ) * ( Y - X ) + X, 0 )`

In general, you can use the above formula to generate random integer numbers between two values X and Y.

`= ROUND ( RAND ( ) * 9 + 1, 0 )`

For example, the above formula will create random integer numbers between 1 and 10.

This is the same formula as before, but using the ROUND function to round to zero decimal places.

You can copy this formula down the column on the spreadsheet, and if you keep pressing F9 to re-calculate, you will see various combinations of numbers from 1 to 10.

Since the set of possible numbers is discrete, the random numbers generated may well be duplicated in the list, depending on what the minimum and maximum are of the range.

`= ROUND ( RAND ( ) * ( 4 - -3 ) + -3, 0 )`

This also works for producing negative numbers. Suppose you need to generate random integer numbers between -3 and 4, then the above formula will be what you need.

Multiplying the RAND function by 7 will produce random numbers between 0 and 7. Add -3 to the result and round to zero decimal places, and this will give the range of random numbers of -3 to 4.

## Generate Random Numbers using the RANDBETWEEN Function

Excel has a useful function for generating random numbers within a range of an upper and lower number.

This is easier to use than using the RAND function as it includes extra operators to arrive at your specific range.

### Syntax for the RANDBETWEEN Function

`= RANDBETWEEN ( bottom, top )`

**bottom**is the lower range for the values to return.**top**is the upper range for the values to return.

Both of these arguments are required.

This function will produce random integer numbers between the bottom and top values. This function will also return the upper and lower limits as possible values as itâs not strictly between in this function.

### Example with the RANDBETWEEN Function

`= RANDBETWEEN ( -3, 4 )`

For example, if you wanted random numbers between -3 and 4, as in the previous example, you can use the above formula.

Notethat the RANDBETWEEN function can only produce integer numbers. There is no way of making the function produce decimal numbers. However, it is considerably less complicated than using the RAND function with operators to achieve the same result.

## Generate Random Numbers with the RANDARRAY Function

Usually, itâs the case that you donât want just a single random value but an entire set of random values.

The RANDARRAY function is the perfect solution for this.

It will populate a range of cells with an array of random numbers, which can be very powerful.

This function is only available on the Microsoft 365 version of Excel.

### Syntax for the RANDARRAY Function

`= RANDARRAY ( [rows], [columns], [min], [max], [whole_number] )`

**Rows**is the number of rows to return.**Columns**is the number of columns to return.**Min**is the minimum value for the random numbers.**Max**is the maximum value for the random numbers.**Whole_Number**is TRUE to return whole numbers, and FALSE to return decimal numbers.

All the arguments are optional for this function.

If no parameters are included, you will get a single random number with decimal places, in the same way as the RAND function.

### Example with the RANDARRAY Function

`= RANDARRAY ( 4, 3, 6, 14, TRUE )`

To generate an array of 4 rows and 3 columns of whole random numbers between 6 and 14 you can use the above formula.

This will produce an array of values. Notice the blue border around the numbers? These are all produced from a single formula!

Notethat the top left-hand corner of the array is always anchored on the cell that the formula is in. Pressing F9 to recalculate the spreadsheet will change all the numbers in the array.(Video) Excel Random Number Generator

If you do not put a minimum or maximum value, the default of 0 to 1 will be used.

The minimum value must be less than the maximum value otherwise there will be a **#VALUE!** error.

The array will automatically resize if you change either the **rows** or **columns** parameters in the **RANDARRAY** formula. This is why theyâre known as dynamic arrays.

Warning: If there is already data in one of the cells in the output range that you have entered, you will get a#SPILL!error. No data will be overwritten.

## Generate Random Numbers with the Analysis Tools Add-In

There is another method that can be used to insert random numbers without using a formula.

You can use an add-in to create random numbers. Excel comes with an **Analysis Tool Pak** add-in, but you will need to install it before you can use it.

### Install the Analysis Toolpak

Here are the steps to install the **Analysis Tool Pak** add-in.

- Click on the
**File**tab in the ribbon.

- In the lower left-hand pane of the window, scroll down and click on
**Options**. You can also use the keyboard shortcut**Alt**,**F**,**T**from the spreadsheet window to open the**Options**window.

- In the left-hand pane of the pop-up window, click on
**Add-Ins.** - At the bottom of the main window displayed, select
**Excel Add-ins**from the dropdown and click on the**Go**button.

- This will display a pop-up window containing all available add-ins for Excel. Check the box for
**Analysis ToolPak**and then click**OK**.

- On the Excel ribbon, on the
**Data**tab, there is now an extra group called Analysis with one button called**Data Analysis**.

### Generate Random Numbers with the Analysis Toolpak

Click on the **Data Analysis** button in the **Analysis** group.

This will display a pop-up window. Scroll down and select the **Random Number Generation** option and then click **OK**.

A new pop-up window will appear where you can enter your parameters to generate the random numbers.

There are several settings that can be customized.

**Number of Variables**This is the number of columns of random numbers that you want in your output table. If left blank, then all columns will be filled in the output range that you specify.**Number of Random Numbers**This is the number of rows of random numbers that you want to generate. If left blank, the output range that you specify will be filled.**Distribution**You can select several distribution methods from the drop-down such as uniform or normal distribution. Different options will become available in the**Parameters**section depending on your selection here.**Parameters**Enter the values to characterize the distribution selected.**Random Seed**This is optional and will be the starting point for the algorithm to produce the random numbers. If you use the same seed again, it will produce the same random numbers. If left blank, it will take the seed value from the timer event.**Output Range**Enter the upper left cell of where the table is to be constructed in the spreadsheet. If you have left the Variables parameter blank, then you will need to specify an entire range. Note that existing data in that range will be overwritten.**New Worksheet Ply**This option will insert a new worksheet within the workbook and will paste the results at Cell A1. Enter a sheet name in the adjacent box, otherwise, a default name will be used.**New Workbook**This will create a new workbook and paste the results into cell A1 in the first sheet.

Press the **OK** button and Excel will insert the random number according to the selected options.

Notice that unlike the formula methods previously shown, these numbers are hardcoded and will not change when you refresh calculations in the workbook.

## Generate Random Numbers with VBA

VBA (Visual Basic for Applications) is the programming language that sits behind the front end of Excel, and this can also be used to generate random numbers.

However, it is more complicated than simply entering a formula into a cell in Excel, and you do need some programming knowledge to use it.

To open the VBA editor, use the **Alt** + **F11** keyboard shortcut.

In the left-hand pane of the window (Project Explorer), you will see the workbooks that are open (including add-ins) and the sheets available.

On the menu at the top of the window, click on **Insert** and then click on **Module**. This will add a module window to the current spreadsheet. Paste or add the following code to the module.

`Sub RandomNumber() MsgBox Rnd()End Sub`

Press **F5** to run this, and a message pop-up will appear in Excel with a random number displayed. Press OK and you will return to the code window.

Run the code again and a different random number will be displayed. The random number will be between 0 and 1, but will not include the values of 0 or 1.

You can also give the **Rnd** function a parameter, which is a seed for the starting point of the algorithm to produce the random numbers.

If the seed value is set to a negative number or zero, then the same random number will be displayed each time.

Using VBA functions, you can emulate all the functionality of the front-end methods that have been covered in this article.

`Sub RandomNumberV2() MsgBox Round((Rnd() * 7) + 3)End Sub`

For example, if you wanted to generate whole random numbers between 3 and 10, then you would use the following above code.

This code multiplies the random number, by 7, and then adds 3 to it, and then rounds to zero decimal places.

Suppose that you then wanted to display your random numbers in the grid. You can do this with the following code.

`Sub RandomNumberSheet()Dim M As IntegerFor M = 1 To 5 ActiveSheet.Cells(M, 1) = Round((Rnd(10) * 7) + 3, 0)Next MEnd Sub`

This code uses a **For Next** loop to iterate 5 times through the random number calculation and enter the results in a column of cells starting at cell A1.

Remember that any data already there will be overwritten, and there is no warning or undo feature available. Save any previous work beforehand!

`Sub RandomNumberV2() Randomize (10) MsgBox Round((Rnd() * 7) + 3)End Sub`

There is also a VBA function called **Randomize**. You can use this before the **Rnd** function to reset the seed value to the timer event, or to any parameter given.

## Generate Random Numbers without Duplicates or Repeats

You may well have a situation where you want to generate a range of random numbers, but you do not want to see any duplicate values appearing.

You may want to select 3 random numbers between the numbers from 1 to 10, but where each of the 3 selected numbers is unique.

You could generate random numbers with the **RANDBETWEEN** function and then use the Excel function Remove Duplicates from the ribbon, but this still may not give you all the numbers required.

There are several possible solutions available.

### Solution with RANK.EQ and COUNTIF Functions

If you donât have access to the **RANDARRAY** function in Excel, then you can use a combination of **RANK.EQ** and **COUNTIF** to get unique random numbers.

You can create your random numbers using **RANDBETWEEN **and then use a formula in the next column to rank them thereby giving you a randomly sorted sequence from 1 to 10.

`= RANDBETWEEN ( 1, 10 )`

In cell B2, enter the above formula**. **Copy this formula down so that there are 10 rows of random numbers going down to cell B11.

You will notice that some numbers may be duplicated and some are not shown at all.

You can then use the **RANK.EQ** function to rank them so as to create a sequence from 1 to 10 but that is sorted randomly.

`= RANK.EQ ( B2, $B$2:$B$11 ) + COUNTIF ( $B$2:B2, B2 ) - 1`

In cell C2, enter the above formula.

Note that there are absolute references used (the **$** signs) so that formula references stay fixed as you copy the formula down.

Copy this formula down to cell C11, and this will display all the numbers between 1 and 10, but in random order.

To explain this formula in more depth, it uses two functions **RANK.EQ** and **COUNTIF**.

`= RANK.EQ ( number, ref, [order] )`

**Number**is the number that we want to find the rank of in the array.**Ref**is the array where we want to search for the number.**Order**is optional and allows you to find the rank in either ascending or descending order. If its omitted then ascending order is used.

The **RANK.EQ** function returns the rank of a number within an array of numbers.

`= COUNTIF ( range, criteria )`

**Range**is the range that is being searched for instances of the criteria.**Criteria**is the value to match within the range.

The **COUNTIF** function counts the number of cells based on a given criterion. In this case, it is counting how many times a given random number has appeared in the list.

For each random number the **RANK.EQ** function will determine its ranking position relative to the other random numbers. But if the random numbers contain duplicates, then they will create a tied ranking.

The **COUNTIF** function will compensate for any ties in the ranking and will add one to the rank for each time the random number has previously appeared.

This creates a unique ranking where ties donât get the same rank.

Since this rank is based on a set of random numbers the result is the same as randomizing a list of numbers from 1 to 10.

Now, if you only want 5 non-repeating numbers, you only need to take the first 5 from the ranking list.

### Solution with VBA

You could also use VBA to generate a string of random numbers from 1 to 10 without duplicates.

`Sub RandomNumberNoDuplicates()Dim M As Integer, Temp As String, RandN As IntegerFor M = 1 To 5Repeat: RandN = Round((Rnd(10) * 9) + 1, 0) If InStr(Temp, RandN) Then GoTo Repeat ActiveSheet.Cells(M, 1) = RandN Temp = Temp & RandN & "|"Next MEnd Sub`

This code iterates through values from 1 to 5, generating a random number between 1 and 10 each time.

It tests the random number to check if it has already been generated. This is done by concatenating successful numbers into a string and then searching that string to see if the number has already been used.

If it has been found, then it uses the label **Repeat** to go back and re-generate a new number. This is again tested that it has not already been used. If it is a new number, then it is added to the sheet.

### Solution with Dynamic Arrays

If you have dynamic arrays in Excel, then there is a single formula method to avoid repeating values.

Suppose you want to return 5 numbers from the sequence 1 to 10. You want each number selected to be unique.

This can be done using a combination of the **SEQUENCE**, **SORTBY**, **RANDARRAY**, and **INDEX** functions.

`=INDEX( SORTBY( SEQUENCE(10), RANDARRAY(10) ), SEQUENCE(5))`

The above formula creates a sequence of numbers from 1 to 10.

It then sorts them in a random order using the **SORTBY** function and sorting on a column of random numbers generated by the **RANDARRAY** function. The effect is to sort the sequence in random order.

Now if you want to get 5 random and unique numbers you only need to take the first 5 numbers from the randomly sorted sequence.

This is exactly what the **INDEX** function does! This part of the formula will return the first 5 numbers from the randomly sorted sequence.

## Conclusion

There are several ways to generate random numbers in Excel.

Whether you need whole numbers, decimals, or a range of random numbers with an upper and lower limit, the facility is available. Excel is extremely versatile on this topic.

However, bear in mind that these numbers are pseudo-random numbers generated by an algorithm.

Although the random number generator passes all the tests of randomness, they are not true random numbers.

To be a truly random number, it would have to be driven by a random event happening outside the computer environment.

For most purposes of constructing general simulations and statistical analysis, the Excel random number generator is considered fit for the purpose.

Have you used any of these methods for generating random numbers in Excel? Do you know any other methods? Let me know in the comments below!

## FAQs

### How do I generate 5 random numbers in Excel? âș

Click on the cell where you'd like to generate your random number. Enter the formula **=RANDBETWEEN([LowerLimit],[UpperLimit])**. For example, if you'd like to generate a random number between one and 10, you may enter =RANDBETWEEN(1,10). Press the "Enter" key.

**What is the best way to generate random numbers in Excel? âș**

If you want to use RAND to generate a random number but don't want the numbers to change every time the cell is calculated, you can **enter =RAND() in the formula bar, and then press F9 to change the formula to a random number**. The formula will calculate and leave you with just a value.

**How do I generate multiple random numbers in Excel? âș**

Multiple results

To generate multiple random numbers in multiple cells, select the target cells, enter the RANDBETWEEN function, and press control + enter to enter the same formula in all cells at once.

**How do you generate 100 random samples in Excel? âș**

**How to generate a random sample using Excel**

- Add a new column within the spreadsheet and name it Random_number.
- In the first cell underneath your heading row, type â= RAND()â
- Press âEnter,â and a random number will appear in the cell.
- Copy and paste the first cell into the other cells in this column.

**How do I generate 20 random numbers in Excel? âș**

**Click and hold the square in the bottom-right corner of the cell and drag it down to create 20 values**. Excel will create a series of random numbers between 1 and 20 in randomized order. In the unlikely event that you get a duplicate random decimal in your first row, type = in any empty cell and press Enter.

**How do I randomly generate numbers in Excel without repeating? âș**

**Generate Random Number List With No Duplicates in Excel**

- Select cell B3 and click on it.
- Insert the formula: =RANDBETWEEN(10,30)
- Press enter.
- Drag the formula down to the other cells in the column by clicking and dragging the little â+â icon at the bottom-right of the cell.

**What is the best method to generate true random numbers? âș**

For truly random numbers, **the computer must use some external physical variable that is unpredictable, such as radioactive decay of isotopes or airwave static**, rather than by an algorithm. At the quantum level, subatomic particles have completely random behavior, making them ideal variables of an unpredictable system.

**How do you generate random numbers? âș**

There are two main methods that a computer generates a random number: **true random number generators (TRNGs) and pseudo-random number generators (PRNGs)**. The former uses some phenomenon outside the computer for its number generation, whereas the latter relies on pre-set algorithms to emulate randomnessÂČ.

**How do I auto generate numbers in Excel? âș**

**Fill a column with a series of numbers**

- Select the first cell in the range that you want to fill.
- Type the starting value for the series.
- Type a value in the next cell to establish a pattern. ...
- Select the cells that contain the starting values. ...
- Drag the fill handle.

**How do I randomize multiple choice answers in Excel? âș**

**Using the RAND formula**

- Insert a new column. Insert a column next to the column you wish to randomize. ...
- Input the formula. In the first cell of the column you inserted, type in the RAND formula, which is "=RAND()". ...
- Sort column in ascending order. ...
- Changing the randomization. ...
- Stop the randomization.

### How do you generate random numbers between 1 and 10? âș

Below is the code showing how to generate a random number between 1 and 10 inclusive. **Random random = new Random(); int rand = 0; while (true){ rand = random.** **nextInt(11); if(rand !=** **0) break; } System.**

**How do I generate 1000 random names in Excel? âș**

...

**To apply the formula, we need to follow these steps:**

- Select cell B3 and click on it.
- Insert the formula: =CHOOSE(RANDBETWEEN(1,5),"George","Matt","Ann","Sam","Jennifer")
- Press enter.

**How do I select 10 random data in Excel? âș**

**How to randomly select in Excel with Randomize tool**

- Select any cell in your table.
- Go to the Ablebits Tools tab > Utilities group, and click Randomize > Select Randomly:
- On the add-in's pane, choose what to select: random rows, random columns or random cells.
- Specify the number or percentage for the desired sample size.

**How do I generate a random number from 1 to 49 in Excel? âș**

The statement to write to choose a random number between 1 and 49 would be: **= RANDBETWEEN (1,49)**. Copy the number of random numbers required. The random numbers are updated when any change is made to the excel sheet.

**How do I generate random numbers and text in Excel? âș**

We use the **RANDBETWEEN function to generate an arbitrary number from a top and bottom value**. This function uses the syntax, =RANDBETWEEN(bottom, top) , where the bottom value is the lowest value in the range and top is the highest value in the range.

**How do you randomly generate numbers in sheets? âș**

**How to use the RAND formula in Google Sheets**

- Open a spreadsheet in Google Sheets.
- Select the cell where you want to display the random number.
- Type "=RAND()" into the cell.
- Press Enter. The cell will display a random number between 0 and 1.

**Does Excel have a random number generator? âș**

The RAND function in Excel generates random real numbers greater than or equal to zero and less than one. The returned random numbers, other than zero, are decimal numbers. The formula operates without arguments or parameters. You can copy the formula =RAND() into as many cells as you need random numbers.

**Can Excel generate random numbers within a range? âș**

**The RANDBETWEEN function â = RANDBETWEEN ( bottom, top ) â generates a series of random numbers within a specified range of a higher and lower number**. The function produces random integers between your given values. It's key to note that this function could also return the upper and lower numerals you set as values.

**What are the two ways of generating a set of random numbers? âș**

There are two main types of random number generators: **pseudo-random and true random**. A pseudo-random number generator (PRNG) is typically programmed using a randomizing math function to select a "random" number within a set range.

**How many methods are used in generating random numbers? âș**

There are **two principal methods** used to generate random numbers. The first method measures some physical phenomenon that is expected to be random and then compensates for possible biases in the measurement process.

### Is there a pattern to random number generators? âș

But it turns out some â even most â computer-generated "random" numbers aren't actually random. **They can follow subtle patterns that can be observed over long periods of time, or over many instances of generating random numbers.**

**What is the formula for random numbers? âș**

If we wish to generate a random number between two numbers, we can use the formula: **RAND() * (b â a) + a**, where a is the smallest number and b is the largest number that we wish to generate a random number for.

**How to generate a random number in C between 1 and 5? âș**

We can generate random numbers in C between 1 and 10 **using rand() and srand() functions**. After passing the seed to srand(), we can calculate it by (rand() % 10) + 1.

**How do I generate a random number array in Excel? âș**

The RANDARRAY function returns an array of random numbers. You can specify the number of rows and columns to fill, minimum and maximum values, and whether to return whole numbers or decimal values. In the following examples, we created an array that's 5 rows tall by 3 columns wide.

**How do I generate random text and numbers in Excel? âș**

We use the **RANDBETWEEN function to generate an arbitrary number from a top and bottom value**. This function uses the syntax, =RANDBETWEEN(bottom, top) , where the bottom value is the lowest value in the range and top is the highest value in the range.

**How do I randomly generate numbers and letters in Excel? âș**

**Instructions**

- Type = to begin your formula.
- Add the CHAR function to create a character.
- Add the randbetween function to make the character random.
- Add 65, 90 to make it a letter from the alphabet.
- Press Enter to complete the formula: =CHAR(randbetween(65,90)).

**How do you generate a random number without using random function? âș**

**1.**

**Middle square method (MSM)**

- Start with an n-digit number as the seed. Let's say it's a 2-digit number 42.
- Square it. Here, the square of 42 is 1764.
- Extract the middle n-digits of the squared number to get the next number in our sequence. ...
- Use the result as the seed and repeat steps 1-4 for the next cycle.