Home Topics excel How to get random sample in Excel with no duplicates

How to get random sample in Excel with no duplicates

Apr 01, 2025 am 09:05 AM

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 to get random sample in Excel with no duplicates

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})

How to get random sample in Excel with no duplicates

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:

  1. Generate random numbers in B2:B10 using =RAND().
  2. 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)
  3. Copy this formula down to select the desired number of values.

How to get random sample in Excel with no duplicates

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."

How to get random sample in Excel with no duplicates

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!

Statement of this Website
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

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

Video Face Swap

Video Face Swap

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

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1664
14
PHP Tutorial
1269
29
C# Tutorial
1249
24
MEDIAN formula in Excel - practical examples MEDIAN formula in Excel - practical examples Apr 11, 2025 pm 12:08 PM

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

Google Spreadsheet COUNTIF function with formula examples Google Spreadsheet COUNTIF function with formula examples Apr 11, 2025 pm 12:03 PM

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

Excel shared workbook: How to share Excel file for multiple users Excel shared workbook: How to share Excel file for multiple users Apr 11, 2025 am 11:58 AM

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

How to convert Excel to JPG - save .xls or .xlsx as image file How to convert Excel to JPG - save .xls or .xlsx as image file Apr 11, 2025 am 11:31 AM

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

Google sheets chart tutorial: how to create charts in google sheets Google sheets chart tutorial: how to create charts in google sheets Apr 11, 2025 am 09:06 AM

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

Excel dynamic named range: how to create and use Excel dynamic named range: how to create and use Apr 11, 2025 am 10:19 AM

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

How to flip data in Excel columns and rows (vertically and horizontally) How to flip data in Excel columns and rows (vertically and horizontally) Apr 11, 2025 am 09:05 AM

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

How to do calculations in Excel How to do calculations in Excel Apr 11, 2025 am 10:20 AM

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

See all articles