Function Problems

Create a Unique Random Sample Without Duplicates in Excel

Huda QurayshiHuda Qurayshi Nov 12, 2026 869 views

Question details

Create a random sample of 29 records from a population of 116 records without selecting any record more than once.

Create a Unique Random Sample Without Duplicates in Excel
Product
Microsoft Excel
Device & OS
not provided
Scenario
The user needs to randomly choose a fixed number of unique rows from a source list.
Observed behavior
The desired result is a shuffled selection containing 29 different records, with no duplicates.
Before you start

Confirm that the source list contains only the records you want to sample and that the requested sample size does not exceed the number of available rows. The dynamic-array formula below requires a version of Excel that supports SORTBY, RANDARRAY, and SEQUENCE.

Solution 1Recommended

Shuffle the full range and return the first 29 unique records

Use this method in modern Excel to generate a random sample without replacement from a single-column list.

RANDARRAY assigns a new random value to every source record, SORTBY uses those values to shuffle the list, and INDEX returns the first 29 rows of the shuffled result. Because each source row is shuffled only once, the returned records are unique.

1
Select an empty output cell

Click an empty cell where the 29 sampled records can spill into adjacent cells, such as C2.

2
Enter the random sampling formula

Type =INDEX(SORTBY(A2:A117,RANDARRAY(ROWS(A2:A117))),SEQUENCE(29)) and press Enter. Replace A2:A117 with the full range containing your 116 records.

3
Review the spilled sample

Excel returns 29 randomly ordered records below the formula cell. Each result comes from a different row in the source range.

4
Keep one generated sample if needed

To stop the sample from changing, select the returned results, press Ctrl+C, then use Home > Paste > Paste Values to save the current records as fixed values.

Shuffle the full range and return the first 29 unique records
The sample changes during recalculation: RANDARRAY recalculates when the workbook recalculates. Paste the output as values when you need to preserve a specific sample.
Random sampling in spreadsheets

Create a duplicate-free random sample in WPS Spreadsheets

WPS Spreadsheets can shuffle a source list with dynamic-array functions and return a fixed number of unique records. Enter the sampling formula in an empty area, then paste the results as values when you want to keep the selected sample.

  1. 1. Open the worksheet in WPS Spreadsheets: Open your .xlsx workbook in WPS Office and locate the column that contains the full population list.
  2. 2. Choose an empty output cell: Click a blank cell with enough space below it for the requested sample, such as C2.
  3. 3. Enter the sampling formula: Enter =INDEX(SORTBY(A2:A117,RANDARRAY(ROWS(A2:A117))),SEQUENCE(29)) and press Enter, updating the range and sample size as needed.
  4. 4. Fix the selected records: Select the spilled results, choose Home > Paste > Paste Special > Values, and save the workbook to retain that random sample.
Randomly select unique records without sampling the same row twiceUse RANDARRAY, SORTBY, INDEX, and SEQUENCE for automatic samplingOpen and edit Microsoft Excel .xlsx files with compatible spreadsheet workflowsUse a familiar spreadsheet interface for sorting, formulas, and paste-as-values actions
QA img-9

Frequently Asked Questions

Why does the random sample change every time I edit the worksheet?

The RANDARRAY function recalculates with the workbook. To retain a specific selection, copy the returned sample and use Home > Paste > Paste Values.

How do I sample entire rows instead of values from one column?

Change the source range in the formula to include all required columns, for example A2:D117. SORTBY will shuffle the rows together, and INDEX with SEQUENCE(29) returns the first 29 shuffled rows.

Can I request more than 29 records with this formula?

Yes. Replace SEQUENCE(29) with the number of records you need, but do not use a number larger than the number of records in the source range.

Does sorting by RANDARRAY create duplicate records?

No. The method shuffles the existing source rows and returns a subset of them. It does not randomly draw the same source row repeatedly, so each selected row appears only once.