How to Use Random 5 Digit Number Generator in Excel (7 Methods)

Method 1 – Using the Excel RANDBETWEEN Function 

Steps:

  • Enter the below formula in Cell B5 and press Enter.
=RANDBETWEEN(10000,99999)

Excel RANDBETWEEN Function as 5 Digit Number Generator

  • We will get the below 5-digit number.
  • Use the Fill Handle (+) tool to get 5-digit numbers over B6:B10.

Excel RANDBETWEEN Function as 5 Digit Number Generator

We will get the below output.

Excel RANDBETWEEN Function as 5 Digit Number Generator

Note:

The RANDBETWEEN function is a volatile function. Random numbers generated by this function change every time a cell on the worksheet is calculated. If you want to avoid these changes in numbers,

  • Enter the random numbers generated by the RANDBETWEEN formula by following Home > Copy or Ctrl + C.

Excel RANDBETWEEN Function as 5 Digit Number Generator

  • Paste them as Values by following Home > Paste > Paste Values (see screenshot).

Excel RANDBETWEEN Function as 5 Digit Number Generator

  • You will get the numbers as values.


Method 2 – Using LEFT & RANDBETWEEN Functions

Steps:

  • Enter the below formula in Cell B6 and hit Enter. The formula will return an empty cell.
=LEFT(RANDBETWEEN(1,9)&RANDBETWEEN(0,999999999999999)&RANDBETWEEN(0,999999999999999),B5)

Generate Random 5 Digit Number with LEFT & RANDBETWEEN Functions

  • Enter 5 in Cell B5 as you need a random number with 5 digits.
  • Press Enter. You will get a 5-digit random number.

Formula Breakdown

  • RANDBETWEEN(1,9)

Here, the above formula returns a random number between 1 and 9.

  • RANDBETWEEN(0,999999999999999)

Here, the RANDBETWEEN function returns a random number between 0 and 999999999999999.

  • LEFT(RANDBETWEEN(1,9)&RANDBETWEEN(0,999999999999999)&RANDBETWEEN(0,999999999999999),B5

Lastly, the above formula returns a random number containing the length of Cell B5.


Method 3 – Using ROUND & RAND Functions in Excel.

Steps:

  • Enter the below formula in Cell B5 and press Enter.
=ROUND(RAND()*(99999-10000)+10000,0)

Create 5 Digit Number Using ROUND & RAND Functions in Excel

  • You will see the below 5-digit numbers.

Formula Breakdown

  • RAND()

Here, the RAND function generates random decimal numbers.

  • RAND()*(99999-10000)+10000

In this part, the result of the RAND function is multiplied by 89999 and then added to 1000.

  • ROUND(RAND()*(99999-10000)+10000,0)

Finally, the ROUND function rounds the result of the previous formula to zero decimal places.


Method 4 – Using Combine INT & RAND Functions

Steps:

  • Enter the below formula in Cell B5 and press Enter.
=INT(RAND()*(99999-10000)+10000)

Combine INT & RAND Functions as 5 Digit Number Generator

  • You will get the following output.

Formula Breakdown

Here, the above formula works similarly to Method 3. The RAND function generates random decimal numbers. The resulting decimal number is multiplied by 89999 and added to 1000. Lastly, the INT function rounds the number to the nearest 5-digit integer.


Method 5 – Using the RANDARRAY Function

Steps:

  • Enter the following formula in Cell B5:
=RANDARRAY(6,2,10000,99999,TRUE)

Create Random 5 Digit Number with RANDARRAY Function

  • Press Enter. The above formula returns 5-digit random numbers (integers) over columns B & C and rows 5:10.


Method 6 – Using the Analysis ToolPak 

Steps:

  • Go to the File tab from the ribbon.

Apply Analysis ToolPak to Generate 5 Digit Numbers in Excel

  • Select Options.

Apply Analysis ToolPak to Generate 5 Digit Numbers in Excel

  • The Excel Options dialog will appear.
  • Click on Add-ins.
  • Check Excel Add-ins selected from the Manage drop-down menu and press Go.

Apply Analysis ToolPak to Generate 5 Digit Numbers in Excel

  • The Add-ins dialog will open.
  • Check on Analysis ToolPak and press OK.

Apply Analysis ToolPak to Generate 5 Digit Numbers in Excel

  • Go to the Data tab, and the Data Analysis option will open. Click on it.

Apply Analysis ToolPak to Generate 5 Digit Numbers in Excel

  • The Data Analysis dialog box appears.
  • Select Random Number Generation from the Analysis Tools list, and press OK.

Apply Analysis ToolPak to Generate 5 Digit Numbers in Excel

  • Enter 2 as the Number of Variables and 6 as the Number of Random Numbers.
  • Choose Uniform from the Distribution drop-down. In the Parameters section, enter the range of 5-digit numbers (10000 and 99999) in the Between field.
  • Select the Output Range and choose the destination cell (here, cell $B$5).
  • Press OK to close the dialog.

Apply Analysis ToolPak to Generate 5 Digit Numbers in Excel

  • We can see the output below.

Note: The 5-digit random numbers generated by Analysis ToolPak contain decimals. To convert those numbers to zero decimal places, you can use the ROUND or INT functions (described in Methods 4 and 5).


Method 7 – Using Excel VBA 

Steps:

  • Go to the sheet where you want to get the 5-digit random numbers.
  • Right-click on the sheet name and select View Code to bring up the VBA window.

Apply Excel VBA as 5 Digit Number Generator

  • Enter the below code in the Module and run it using F5.
Sub Random5DigitNumber()
Dim N As Integer
For N = 5 To 10
    ActiveSheet.Cells(N, 2) = Round(Rnd() * (99999 - 10000) + 10000, 0)
Next N
End Sub

Apply Excel VBA as 5 Digit Number Generator

  • You will get the below 5-digit numbers.


Things to Remember

  • The result we receive from the RANDBETWEEN function contains duplicates. To detect the duplicate numbers, you can use the RANK.EQ function in Excel.
  • The RAND function is also a volatile function. You can convert the results returned by the RAND formula to values using the Paste Special option.

Download the Practice Workbook

You can download the workbook to practice.


<< Go Back to Random Number in Excel | Randomize in Excel Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Hosne Ara
Hosne Ara

Hosne Ara is a materials and metallurgical engineer who loves exploring Excel and VBA programming. To her, programming is like a time-saving superhero for dealing with data, files, and the internet. She's skilled in Rhino3D, Maxsurf C++, MS Office, AutoCAD, and Excel & VBA, going beyond the basics. With a B. Sc. in Materials and Metallurgical Engineering from Bangladesh University of Engineering and Technology, she's shifted gears and now works as a content developer. In this role, she... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo