To randomize a dataset in Excel, the reliable method is to add a helper column filled with the RAND() function, copy that column and paste it back as values, then sort the whole table by that column. Rows keep their internal order but shuffle against each other, which is exactly what you want for a random sample, a shuffled survey order, or a fair draw. You can also target a reproducible shuffle with RANDARRAY() or a seeded random number generator if your version of Excel includes one. This guide walks through the cleanest route first, then covers the variations and the traps that cause broken datasets.
What You'll Need
- A dataset laid out in tabular form: one header row, one record per row, no merged cells inside the data range.
- Excel on Windows, Mac, or the web app. The Classic sort-and-fill method works on all of them;
RANDARRAY()requires Microsoft 365 or Excel 2021 and later. - A backup copy of the file, or Save As before you start, because sorting is destructive to the original row order.
- An empty column immediately to the right of your data, or anywhere in the sheet, for the helper values.
Step-by-Step
- Save a copy first. Use File > Save As and give the file a new name, or duplicate the sheet by right-clicking the sheet tab and choosing Move or Copy with Create a copy ticked. Sorting is permanent once you save, and there is no built-in undo for a shuffle after you close the file.
- Turn your data into a proper table. Click any cell inside the data and press Ctrl+T (Cmd+T on Mac). Confirm the header row in the dialog. A real table means Excel treats the whole record as one unit, so sorting never separates a name from its email in the next column. If you prefer not to use tables, at least confirm the contiguous range has no blank rows or columns, because Excel's sort only extends across the block it detects.
- Add a header for the helper column. In the first empty column to the right, type
Randomin the row level with your headers. Giving it a name keeps the sort dialog readable and prevents Excel from treating the first value as data. - Enter the RAND formula. In the cell below the header, type
=RAND()and press Enter. This returns a decimal between 0 and 1. Every recalculation produces a new one, which is why the next two steps matter. - Fill the formula down. Double-click the small square at the bottom-right corner of the cell (the fill handle), or drag it to the last row. Alternatively, select the cell, copy it with Ctrl+C, select the rest of the column and paste. Every row must get its own value; a row with a blank helper cell tends to land at the top or bottom of the sort.
- Freeze the values. With the helper column still selected, copy it, then right-click and choose Paste Special > Values (or Paste Special, then the Values button). This replaces the live formulas with fixed numbers. Without this step, the next click anywhere in the workbook recalculates and reshuffles, which silently corrupts any sorting you have already done.
- Sort by the helper column. Click any cell in the Random column, then go to Data > Sort. Set Sort by to the Random header, Sort On to Cell Values, and Order to Smallest to Largest (or Largest to Smallest, it makes no difference). Make sure My data has headers is ticked. Click OK.
- Check the result. Scan the top and bottom rows. Confirm names still sit beside their correct email, phone or score. If a whole column shifted out of alignment, you sorted a range that excluded one column, so undo with Ctrl+Z and re-sort by selecting the entire table first.
- Take your sample if that was the goal. With the rows shuffled, the top n rows are now a simple random sample without replacement. Copy them to a new sheet or delete the rest.
- Tidy up. Delete the Random helper column, or keep it if you want an audit trail of the shuffle order. Then save.
Note that menu labels differ slightly by version, device and region. On Excel for the web the Paste Special options live under a right-click context menu or Home > Paste > Paste Special; on Mac, the Sort dialog is under Data > Sort and looks a little different from the Windows version, but the options are the same.
Common Mistakes
- Sorting with live RAND formulas. If you sort before pasting as values, the formulas recalculate during the sort and you get an unpredictable, sometimes near-original order. Always freeze first.
- Sorting only one column. Selecting just the name column and hitting the A-Z button sorts those names independently and detaches them from the rest of the record. Select the whole table, or use a real Excel table.
- Blank rows in the middle. Excel stops at the first gap when it guesses the range. Remove blank rows or select the full range manually before sorting.
- Merged cells. Merged cells inside the data range break sorting with a warning and sometimes a partial result. Unmerge them first.
- Expecting RAND to stay put.
RAND()is volatile: it recalculates on every edit, open, and recalculation. That is a feature when you want a fresh shuffle, and a bug when you want a fixed one. - Randomizing a list with duplicate identifiers. If the sort seems not to have changed anything, your rows may already be indistinguishable, or you sorted a single column instead of the table.
Tips
- To get a fresh random order, just replace the helper column with a new
=RAND()fill and paste values again. Reusing an old frozen column gives you the same shuffle every time. - For a random sample of a fixed size, avoid deleting rows by eye. Add a second helper column with
=RAND(), freeze it, sort, and copy the first n rows to a separate sheet so your source data stays intact. - Need random assignment to groups (A/B, control/treatment)? Shuffle, then in a new column use
=IF(ROW()-1<=n,"A","B")style logic, or simply fill alternating labels after sorting. RANDBETWEEN(1,1000)gives integer ranks, which are easier to eyeball than long decimals, though ties are possible.RAND()avoids ties almost entirely.- If you have Microsoft 365,
=SORTBY(A2:C100,RANDARRAY(ROWS(A2:C100)))produces a shuffled copy in one formula. Keep the source range untouched and paste the result as values when you are happy with it. - For a shuffle you can repeat exactly, use
=RANDARRAY(rows,1,0,1,TRUE)in a version that supports a seed argument, and record the seed. Without a seed the order changes on every recalculation. - Format the helper column to show several decimal places so you can visually confirm the values are not tied.
Troubleshooting
The order did not change after sorting. The helper column probably holds live formulas and recalculated during the sort, or the sort range excluded it. Undo, paste the helper column as values, then re-sort with the entire table selected.
Data ended up misaligned. You sorted a partial range. Press Ctrl+Z immediately. If you have already saved, restore from the backup copy or use File > Info > Version History to recover an earlier version.
Excel refuses to sort. Look for merged cells, blank rows, or a protected sheet. Unmerge, fill the gaps, and check Review > Unprotect Sheet if the workbook is locked.
Every value in the helper column is identical. You may have filled a single value down without relative references, or the column is formatted as text. Re-enter =RAND() in the first cell with the cell formatted as General or Number, then refill.
The shuffle keeps changing on its own. The helper column still contains formulas. Select it, copy, Paste Special > Values, and save.
RANDARRAY or SORTBY shows a #NAME? error. Your Excel version does not support dynamic arrays. Use the manual helper-column method instead, which works everywhere.
Frequently Asked Questions
Does RAND() ever produce duplicates?
In theory yes, but the chance is vanishingly small because it returns a decimal with many digits. If you need guaranteed uniqueness, use RANDBETWEEN and accept possible ties, or add a tie-breaker column such as row number and sort by both.
Will randomizing break my formulas that reference other rows?
It can. Relative references and lookups that depend on row position will now point at different records. Convert formulas to values before shuffling, or make your lookups key-based with XLOOKUP, VLOOKUP or INDEX and MATCH so they follow the identifier rather than the position.
How do I get the same random order again later?
Keep the frozen helper column in the file, or save the shuffled result on a separate sheet. Because a frozen column is just numbers, sorting by it again reproduces the exact same order. A live formula cannot do this without a seed.
Can I randomize only part of the dataset?
Yes. Select just the rows you want to shuffle, including the helper column, and sort that selection. Rows outside the selection stay where they are. Make sure the selection contains whole records, not single columns.
Is there a one-click randomize button in Excel?
No. Excel has no built-in shuffle command. The helper-column and sort method is the standard approach, and it is what Microsoft's own guidance on random sampling describes.