search
HomeTopicsexcelHow to generate random numbers in Excel with no repeats

In this article, we'll discuss a few different formulas to randomize in Excel without repeating numbers. Also, we will show you a universal Random Generator that can produce a list of random numbers, dates, and strings with no repeats.

As you probably know, Microsoft Excel has several functions for generating random numbers such as RAND, RANDBETWEEN and RANDARRAY. However, there is no guarantee that the result of any function will be duplicate free.

This tutorial explains a few formulas for creating a list of unique random numbers. Please pay attention that some formulas only work in the latest version of Excel 365 and 2021 while others can be used in any version of Excel 2019, Excel 2016, Excel 2013 and earlier.

Get a list of unique random numbers with predefined step

Only works in Excel 365 and Excel 2021 that support dynamic arrays.

If you have the latest Excel version, the easiest way for you to get a list of unique random numbers is to combine 3 new dynamic array functions: SORTBY, SEQUENCE and RANDARRAY:

SORTBY(SEQUENCE(n), RANDARRAY(n))

Where n is the number of random values you want to get.

For example, to create a list of 5 random numbers, use 5 for n:

=SORTBY(SEQUENCE(5), RANDARRAY(5))

Enter the formula in the topmost cell, press the Enter key, and the results will spill automatically over the specified number of cells.

As you can see in the screenshot below, this formula actually sorts numbers from 1 to 5 in random order. If you need a classic random number generator with no repeats, then please check out other examples that follow below.

How to generate random numbers in Excel with no repeats

In the above formula, you only define how many rows to fill. All other arguments are left to their default values, meaning the list will start at 1 and will be incremented by 1. If you'd like a different first number and increment, then set your own values for the 3rd (start) and 4th (step) arguments of the SEQUENCE function.

For instance, to start at 100 and increment by 10, use this formula:

=SORTBY(SEQUENCE(5, , 100, 10), RANDARRAY(5))

How to generate random numbers in Excel with no repeats

How this formula works:

Working from the inside out, here's what the formula does:

  • The SEQUENCE function creates an array of sequential numbers based on the specified or default start value and incrementing step size. This sequence goes to the array argument of SORTBY.
  • The RANDARRAY function creates an array of random numbers of the same size as the sequence (5 rows, 1 column in our case). The min and max value do not really matter, so we can leave these to defaults. This array goes to the by_array argument of SORTBY.
  • The SORTBY function sorts the sequential numbers generated by SEQUENCE using an array of random numbers produced by RANDARRAY.

Please keep in mind that this simple formula creates a list of non repeating random numbers with a predefined step. To bypass this limitation, use an advanced version of the formula described below.

Generate a list of random numbers with no duplicates

Only works in Excel 365 and Excel 2021 that support dynamic arrays.

To generate random numbers in Excel without duplicates, use one of the below generic formulas.

Random integers:

INDEX(UNIQUE(RANDARRAY(n^2, 1, min, max, TRUE)), SEQUENCE(n))

Random decimals:

INDEX(UNIQUE(RANDARRAY(n^2, 1, min, max, FALSE)), SEQUENCE(n))

Where:

  • N is the number of values to generate.
  • Min is the minimal value.
  • Max is the maximum value.

For example, to create a list of 5 random integers from 1 to 100 with no repeats, use this formula:

=INDEX(UNIQUE(RANDARRAY(5^2, 1, 1, 100, TRUE)), SEQUENCE(5))

How to generate random numbers in Excel with no repeats

To generate 5 unique random decimal numbers, put FALSE in the last argument of RANDARRAY or omit this argument:

=INDEX(UNIQUE(RANDARRAY(5^2, 1, 1, 100)), SEQUENCE(5))

How to generate random numbers in Excel with no repeats

How this formula works:

At first sight the formula may look a bit tricky, but upon a closer look its logic is very straightforward:

  • The RANDARRAY function creates an array of random numbers based on the min and max values that you specify. To determine how many values to generate, you raise the desired number of uniques to the power of 2. Because the resulting array may have no one knows how many duplicates, you need to provide a sufficient array of values for UNIQUE to choose from. In this example, we need only 5 unique random numbers but we instruct RANDARRAY to produce 25 (5^2).
  • The UNIQUE function removes all duplicates and "feeds" a duplicate-free array to INDEX.
  • From the array passed by UNIQUE, the INDEX function extracts the first n values as specified by SEQUENCE (5 numbers in our case). Because values are already in random order, it does not really matter which ones survive.

Note. On very large arrays, this formula may be a bit slow. For example, to get a list of 1,000 unique numbers as the final result, RANDARRAY would have to generate of array of 1,000,000 random numbers (1000^2) internally. In such situations, instead of raising to power, you can multiply n by, say, 10 or 20. Just keep in mind please that the smaller array is passed to the UNIQUE function (small relative to the desired number of unique random values), the bigger the chance that not all cells in the spill range will be filled with the results.

Create a range of non-repeating random numbers in Excel

Only works in Excel 365 and Excel 2021 that support dynamic arrays.

To generate a range of random numbers with no repeats, you can use this formula:

INDEX(UNIQUE(RANDARRAY(n^2, 1, min, max)), SEQUENCE(rows, columns))

Where:

  • n is the number of cells to fill. To avoid manual calculations, you can supply it as (no. of rows * no. of columns). For example, to fill 10 rows and 5 columns, use 50^2 or (10*5)^2.
  • Rows is the number of rows to fill.
  • Columns is the number of columns to fill.
  • Min is the lowest value.
  • Max is the highest value.

As you may notice, the formula is basically the same as in the previous example. The only difference is the SEQUENCE function, which in this case defines both the number of rows and columns.

For instance, to fill a range of 10 rows and 3 columns with unique random numbers from 1 to 100, use this formula:

=INDEX(UNIQUE(RANDARRAY(30^2, 1, 1, 100)), SEQUENCE(10, 3))

And it will produce an array of random decimals without repeating numbers:

How to generate random numbers in Excel with no repeats

If you need whole numbers, then set the last argument of RANDARRAY to TRUE:

=INDEX(UNIQUE(RANDARRAY(30^2, 1, 1, 100, TRUE)), SEQUENCE(10,3))

How to generate random numbers in Excel with no repeats

How to generate unique random numbers in Excel 2019, 2016 and earlier

As no version other than Excel 365 and 2021 supports dynamic arrays, none of the above solutions work in earlier versions of Excel. However, this does not mean there is no solution at all, you'll just have to perform a few more steps:

  1. Create a list of random numbers. Based on your needs, use either:
    • The RAND function to generate random decimals between 0 and 1, or
    • The RANDBETWEEN function to produce random integers in the range that you specify.

    Be sure to generate more values than you actually need because some will be duplicates and you'll delete them later.

    For this example, we are creating a list of 10 random integers between 1 and 20 by using the below formula:

    =RANDBETWEEN(1,20)

    To enter the formula in multiple cells in one go, select all the cells (A2:A15 in our example), type the formula in the formula bar and press Ctrl Enter. Or you can enter the formula in the first cell as usual, and then drag it down to as many cells as needed.

    Anyway, the result will look something like this:

    How to generate random numbers in Excel with no repeats

    As you may notice, we've entered the formula in 14 cells, though eventually we only need 10 unique random numbers.

  2. Change formulas to values. As both RAND and RANDBETWEEN recalculate with every change on the worksheet, your list of random numbers will be continuously changing. To prevent this from happening, use Paste Special > Values to convert formulas to values as explained in How to stop random numbers from recalculating.

    To make sure you've done it right, select any number and look at the formula bar. It should now display a value, not a formula:

    How to generate random numbers in Excel with no repeats

  3. Delete duplicates. To have it done, select all the numbers, go to the Data tab > Data tools group, and click Remove Duplicates. In the Remove Duplicates dialog box that appears, simply click OK without changing anything. For the detailed steps, please see How to remove duplicates in Excel.

    How to generate random numbers in Excel with no repeats

Done! All duplicates are gone, and you can now delete the excess numbers.

Tip. Instead of Excel's built-in tool, you can use our advanced Duplicate Remover for Excel.

How to stop random numbers from changing

All of the randomizing functions in Excel including RAND, RANDBETWEEN and RANDARRAY are volatile, meaning they recalculate every time the spreadsheet is changed. As the result, new random values are produced with every change. To prevent generating new numbers automatically, use the Paste Special > Values feature to replace formulas with static values. Here's how:

  1. Select all the cells with your random formula and press Ctrl C to copy them.
  2. Right click the selected range and click Paste Special > Values. Alternatively, you can press Shift F10 and then V, which is the shortcut for this option.

For the detailed steps, please see How to change formulas to values in Excel.

Random number generator for Excel with no repeats

The users of our Ultimate Suite do not really need any of the above solutions because they already have a universal Random Generator in their Excel. This tool can easily produce a list of non-repeating integers, decimals numbers, dates, and unique passwords. Here's how:

  1. On the Ablebits Tools tab, click Randomize > Random Generator.
  2. Select the range to fill with random numbers.
  3. On the Random Generator pane, do the following:
    • Choose the desired value type: integer, real number, date, Boolean, custom list, or string (ideal for generating strong unique passwords!).
    • Set up the From and To values.
    • Select the Unique values check box.
    • Click Generate.

That's it! The selected range gets filled with non-repeating random numbers at once:

How to generate random numbers in Excel with no repeats

If you are curious to try this tool and explore other fascinating features included with our Ultimate Suite, you are welcome to download a trial version.

That's how to randomize numbers in Excel without duplicates. I thank you for reading and hope to see you on our blog next week!

Practice workbook for download

Generate unique random numbers in Excel (.xlsx file)

The above is the detailed content of How to generate random numbers in Excel with no repeats. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
How to create timeline in Excel to filter pivot tables and chartsHow to create timeline in Excel to filter pivot tables and chartsMar 22, 2025 am 11:20 AM

This article will guide you through the process of creating a timeline for Excel pivot tables and charts and demonstrate how you can use it to interact with your data in a dynamic and engaging way. You've got your data organized in a pivo

how to do a drop down in excelhow to do a drop down in excelMar 12, 2025 am 11:53 AM

This article explains how to create drop-down lists in Excel using data validation, including single and dependent lists. It details the process, offers solutions for common scenarios, and discusses limitations such as data entry restrictions and pe

how to sum a column in excelhow to sum a column in excelMar 14, 2025 pm 02:42 PM

The article discusses methods to sum columns in Excel using the SUM function, AutoSum feature, and how to sum specific cells.

how to make pie chart in excelhow to make pie chart in excelMar 14, 2025 pm 03:32 PM

The article details steps to create and customize pie charts in Excel, focusing on data preparation, chart insertion, and personalization options for enhanced visual analysis.

how to make a table in excelhow to make a table in excelMar 14, 2025 pm 02:53 PM

Article discusses creating, formatting, and customizing tables in Excel, and using functions like SUM, AVERAGE, and PivotTables for data analysis.

how to calculate mean in excelhow to calculate mean in excelMar 14, 2025 pm 03:33 PM

Article discusses calculating mean in Excel using AVERAGE function. Main issue is how to efficiently use this function for different data sets.(158 characters)

how to add drop down in excelhow to add drop down in excelMar 14, 2025 pm 02:51 PM

Article discusses creating, editing, and removing drop-down lists in Excel using data validation. Main issue: how to manage drop-down lists effectively.

All you need to know to sort any data in Google SheetsAll you need to know to sort any data in Google SheetsMar 22, 2025 am 10:47 AM

Mastering Google Sheets Sorting: A Comprehensive Guide Sorting data in Google Sheets needn't be complex. This guide covers various techniques, from sorting entire sheets to specific ranges, by color, date, and multiple columns. Whether you're a novi

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version