How to get random sample in Excel with no duplicates
This tutorial demonstrates how to perform random sampling in Excel without duplicates. Solutions are provided for Excel 365, Excel 2021, Excel 2019, and older versions.
Previously, we explored methods for random selection using RAND
and RANDBETWEEN
, which can result in repeated values. This tutorial offers techniques to avoid duplicates.
Excel 365 & 2021: Random Selection from a List without Duplicates
This method leverages dynamic arrays, available in Excel 365 and 2021. The formula:
INDEX(SORTBY(data, RANDARRAY(ROWS(data))), SEQUENCE(n))
where n
represents the desired sample size.
For example, to select 5 unique names from A2:A10:
=INDEX(SORTBY(A2:A10, RANDARRAY(ROWS(A2:A10))), SEQUENCE(5))
The sample size can be referenced from a cell (e.g., C2):
=INDEX(SORTBY(A2:A10, RANDARRAY(ROWS(A2:A10))), SEQUENCE(C2))
How it works: RANDARRAY
generates random numbers; SORTBY
shuffles the data based on these numbers; INDEX
retrieves the first n
values using SEQUENCE
.
Excel 365 & 2021: Selecting Random Rows without Duplicates
This extends the previous method to select entire rows. The formula:
INDEX(SORTBY(data, RANDARRAY(ROWS(data))), SEQUENCE(n), {1,2,…})
where {1,2,…}
represents the column numbers to extract.
To select random rows from A2:C10 (sample size in F1):
=INDEX(SORTBY(A2:C10, RANDARRAY(ROWS(A2:C10))), SEQUENCE(F1), {1,2,3})
The logic remains the same, but INDEX
now uses both row and column indices.
Excel 2019 - 2010: Random Sampling
Since dynamic arrays are unavailable in older versions, a different approach is needed. For random selection from A2:A10:
- Generate random numbers in B2:B10 using
=RAND()
. - Extract the first random value in E2 using:
=INDEX($A$2:$A$10, RANK.EQ(B2, $B$2:$B$10) COUNTIF($B$2:B2, B2) - 1)
- Copy this formula down to select the desired number of values.
RANK.EQ
ranks the random numbers; COUNTIF
handles duplicates, ensuring unique selection.
Preventing Sample Changes
Because RAND
, RANDBETWEEN
, and RANDARRAY
are volatile, the sample will change with worksheet edits. Use "Paste Special > Values" to convert formulas to static values.
Excel Random Selection (Rows, Columns, or Cells - All Versions)
The Ablebits Ultimate Suite provides a user-friendly interface for random selection. Select your range, choose rows/columns/cells, specify the sample size, and click "Select."
Downloads:
- Random sample without duplicates - formula examples (.xlsx)
- Ultimate Suite 14-day trial (.exe)
The above is the detailed content of How to get random sample in Excel with no duplicates. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











This tutorial explains how to calculate the median of numerical data in Excel using the MEDIAN function. The median, a key measure of central tendency, identifies the middle value in a dataset, offering a more robust representation of central tenden

Master Google Sheets COUNTIF: A Comprehensive Guide This guide explores the versatile COUNTIF function in Google Sheets, demonstrating its applications beyond simple cell counting. We'll cover various scenarios, from exact and partial matches to han

This tutorial provides a comprehensive guide to sharing Excel workbooks, covering various methods, access control, and conflict resolution. Modern Excel versions (2010, 2013, 2016, and later) simplify collaborative editing, eliminating the need to m

This tutorial explores various methods for converting .xls files to .jpg images, encompassing both built-in Windows tools and free online converters. Need to create a presentation, share spreadsheet data securely, or design a document? Converting yo

This tutorial shows you how to create various charts in Google Sheets, choosing the right chart type for different data scenarios. You'll also learn how to create 3D and Gantt charts, and how to edit, copy, and delete charts. Visualizing data is cru

This tutorial shows you how to create and use dynamic named ranges in Excel, automatically updating calculations as your data changes. Unlike static named ranges, dynamic ranges adjust to include new data without manual intervention. Last week's tut

This tutorial demonstrates several efficient methods for vertically and horizontally flipping tables in Excel, preserving original formatting and formulas. While Excel lacks a direct "flip" function, several workarounds exist. Flipping Dat

This tutorial demonstrates how to perform arithmetic calculations within Microsoft Excel and modify the order of operations in your formulas. Excel's capabilities extend far beyond simple addition; it can handle complex calculations, thanks to its h
