Note: The other languages of the website are Google-translated. Back to English
Log in  \/ 
Register  \/ 


Generate random number with the given specific length in Excel

Today, we may use multiple passwords in our daily work, and the password may be in different length. If you are tired to set a password, you can use formulas or a handy tool to generate random passwords for you. Here this tutorial provides some tricks to generate random numbers in your desired length in Excel.

Random number in a given specific length with using formula

Random number or other characters in a given length with using a handy tool

Sample file

Random number in a given specific length with using formula

Random number in a fixed length

Supposing you want to generate a random number string in 6-digit length, you can use this formula


Press Enter key, then then a random number in 6-digit length is outputted.

Note: The output number will be changed when every time the worksheet is updated.
doc random number in specific length 1

Random number in a changed length based on the digit number you type in another cell

In some times, you may need to generate passwords in different lengths, for instance, when you type 5 in cell A1, the cell A2 will display a random number in 5-dighit length, if you type 9 in cell A1, the A2 displays a 9-digit number.

Select A2, the type this formula

=LEFT(RANDBETWEEN(1,9)&RANDBETWEEN(0,999999999999999)&RANDBETWEEN(0,999999999999999), A1)

Press Enter key, now it displays blank as the cell A1 is empty.
doc random number in specific length 2

From now on, when you type a number in A1 and press Enter key, it generates a random number in the specific length in cell A2 based on the number you typed in cell A1.

Note: The number will be changed when every time the worksheet is update.
random number fixed length

Random number or other characters in a given length with using a handy tool

If you not only want random number string in length, but also want random decimal number or integer number in a number range, or random text strings, or random date or time or custom list, you can try a handy tool, the Insert Random Data utility of Kutools for Excel.

Kutools for Excel, with more than 300 handy functions, makes your jobs more easier. 

After free installing Kutools for Excel, please do as below:

Select a range of cells you want to generate random data, click Kutools > Insert > Insert Random Data.
doc random number in specific length 3

In the Insert Random Data dialog, choose the data type you want to generate from the tabs, then specify the data scope or settings as you need.

Insert random integers or decimals
doc random number in specific length 4 doc random number in specific length 5

Insert random date or time
doc random number in specific length 6 doc random number in specific length 7

Insert random string or custom list
doc random number in specific length 8 doc random number in specific length 9

Sample file

Click to download sample file

Other Operations (Articles)

Generate random number by given certain mean and standard deviation in Excel
In some certain cases, you may want to generate a series of random numbers based on given specific mean and standard deviation, how could you quickly solve this problem? Now this tutorial will introduce a way for you to handle with it in Excel.

Generate random character strings in a range in Excel
Sometimes you may need to generate random strings in cells, such as different passwords. This article tries to show you some tricks to generate different random strings in Excel.

Generate only random even or odd numbers in Excel
In this tutorial, I will introduce some formulas to help you generate only random even numbers or only random odd numbers in Excel.

Generate random date between two dates quickly in Excel
When you use an Excel file, sometimes you want to generate random date for some purpose, of course, you can enter the date manually one by one, but if you need to insert multiple dates, this method will be time-consuming and boring. How to quickly generate random date on earth in Excel?

  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns and Keeping Data; Split Cells Content; Combine Duplicate Rows and Sum/Average... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Favorite and Quickly Insert Formulas, Ranges, Charts and Pictures; Encrypt Cells with password; Create Mailing List and send emails...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • Pivot Table Grouping by week number, day of week and more... Show Unlocked, Locked Cells by different colors; Highlight Cells That Have Formula/Name...
kte tab 201905
  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom
Say something here...
symbols left.
You are guest
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.

Be the first to comment.