Can You Shuffle Rows in Excel? Safe Ways to Randomize

How-to basics · Updated November 21, 2026

Yes. In Excel for Microsoft 365 on Windows, you can shuffle rows by adding a column of random numbers and sorting the entire table by that column, or by using a dynamic-array formula to display a shuffled copy. The key is to move each complete record together so names, dates, and other fields stay matched.

What shuffling rows means

Shuffling rows means putting records in a random order without changing the values within each record. For example, if a row contains a student’s name, class, and score, all three values must move together. Sorting only the names column would break those relationships and leave the data incorrect.

Excel does not have a dedicated Shuffle button in the standard ribbon. Instead, you create random sort keys and use Excel’s normal sorting tools, or use a formula that returns the records in a randomized order. Neither approach changes the contents of the records themselves, but the formula method displays its result separately from the source data.

A shuffled order is useful for tasks such as mixing a list of presentation topics, creating a randomized order for a classroom activity, or selecting records for a preliminary review. It is not automatically a statistically rigorous sampling process: if you need a formal sample, define the sampling method and any requirements for reproducibility before using a random order.

Method 1: Shuffle rows with a helper column

A helper column is a dependable choice when you want to rearrange the original data in place. In this example, the records are in A2:C11, with headers in A1:C1. Column D will hold a temporary random key.

  1. Type a heading such as RandomKey in D1.
  2. With the records in A2:C11 and the helper values in D2:D11, enter =RAND() in D2. The formula returns a decimal random number from 0 up to, but not including, 1.
  3. Fill the formula down through D11. Each row now has a random sort key. If Excel does not fill the formula automatically, select D2:D11 and use Home > Fill > Down.
  4. To keep the keys from changing during later recalculation, copy D2:D11 and use Home > Paste > Values. The cells now contain fixed numbers rather than volatile formulas.
  5. Select the entire range A1:D11, then choose Data > Sort. Make sure the option indicating that the data has headers is selected, choose RandomKey as the sort column, and sort from smallest to largest. Sorting from largest to smallest also produces a randomized order.
  6. Check that the records have moved together, then delete the temporary helper column if you no longer need it.

The result is the same ten records in a different row order; no record is intentionally added or removed. Sorting a helper key column is safer than sorting one field alone because Excel applies the sort to the selected table range. If Excel asks whether to expand the selection, choose that option so every column in each record moves together.

Method 2: Display a shuffled copy with a formula

A dynamic-array formula can return a randomized copy while leaving the original table in place. This is handy when you want to compare the shuffled order with the source data or keep the original order unchanged. It requires Excel for Microsoft 365 or Excel 2021 or later, which support SORTBY and RANDARRAY.

Assume the source records are in A2:C11, with headers in A1:C1. Select an empty cell outside the source range, such as E2, and enter =SORTBY(A2:C11,RANDARRAY(ROWS(A2:A11))). The formula returns all ten rows from A2:C11, arranged in a random order, and spills the results into nearby cells. It does not include the header row, so add or copy headers separately if you want them above the output.

Leave enough blank space to the right and below E2 for the results to spill. If existing content blocks that area, Excel displays a spill error instead of returning the list. The source remains unchanged, and the displayed output changes when Excel recalculates the formula. This result is a new ordering of the same records, not a guaranteed specific sequence; each recalculation can produce another order.

Dynamic-array formulas return cell values, but you should not assume the output will reproduce every aspect of the source, such as its formatting, column widths, or layout. If you need a fixed copy, copy the spilled results and paste values into a separate range. Dynamic-array formulas also cannot spill from within an Excel table, so put this formula outside the table.

Keep complete records together

The most important safeguard is selecting the full data range before sorting. If a worksheet has columns for customer, order number, date, and amount, all four columns must be included. Otherwise, Excel may sort one selected column independently, which can attach a date or amount to the wrong customer.

  • Include every field that belongs to the records, as well as the helper column, in the sort selection.
  • Use one clear header row and identify it as a header in the Sort dialog. If Excel treats a header as a record, it may move into the shuffled data.
  • Check for blank rows or columns inside the dataset. They can cause Excel to detect only part of the intended range.
  • If your data is an Excel table, confirm that the table includes all relevant columns and rows before sorting.

For high-value or difficult-to-rebuild data, save a copy before changing the order. A sort can usually be undone with Ctrl+Z on Windows, but once more edits are made, undo may no longer restore the earlier state. Keeping a backup is a simple way to preserve the original order.

Why the order can change again

RAND is a volatile function: it can generate new numbers when Excel recalculates. As a result, a helper-column shuffle that still contains RAND formulas may change after an edit or recalculation. The SORTBY and RANDARRAY formula also recalculates, so its displayed order is not a permanent random arrangement.

To preserve a helper-column shuffle, replace the formulas with their values before sorting, as described above. To preserve a formula-generated result, copy the output and paste values into another range. If you want to generate a fresh shuffle, leave the random formulas in place or recalculate the formula output. In Excel for Windows, F9 recalculates formulas; you can also use Formulas > Calculate Now. On a Mac, use Formulas > Calculate Now if you do not want to rely on a keyboard shortcut that can vary with keyboard settings.

Be aware that a fixed random order is not automatically repeatable from a saved formula. If you need to reproduce the same order later, save the shuffled values or record the final sequence. A random formula does not provide a simple seed setting that guarantees the same results on demand.

Which method should you choose?

Choose the helper-column method when the original table itself needs to be reordered, when you need to work in an Excel version without dynamic arrays, or when you want a simple fixed result after replacing the random formulas with values. It is also easier to inspect: each row has a visible key that explains the sort order.

Choose SORTBY with RANDARRAY when you want a separate shuffled view and have a supported Excel version. It avoids rearranging the source and is convenient for a quick preview, but the output changes on recalculation unless you freeze it as values. If you only need to mix a short list once, the helper column is usually the more straightforward choice.

Neither method is a substitute for drawing a specified number of records. To select a sample, shuffle the full list first and take the required number of rows from the top, making sure the full records are included. For regulated, scientific, or other consequential work, check whether a documented sampling procedure or reproducible random-number method is required.

Common problems and fixes

  • Only one column moved: Undo the sort, select the full dataset, and sort again. When prompted, choose to expand the selection rather than sorting only the selected cells.
  • The header moved into the records: Open Data > Sort and mark that the data has headers, or select the correct range with its header row included.
  • The order keeps changing: Replace the RAND helper formulas with values before sorting, or paste the formula output as values.
  • The formula shows a spill error: Clear the cells where the result needs to appear, and enter the formula outside any Excel table.
  • The formula name is not recognized: SORTBY and RANDARRAY require Excel 2021 or Microsoft 365. Use the helper-column approach in an older version.

When a sort looks wrong, first check the selected range and the header setting. Those are common causes of mismatched records. Also inspect for merged cells or blank rows within the data, since unusual layouts can complicate selection and sorting. For a regular dataset, converting it to an Excel table can make it easier to keep related columns together as you sort.

Frequently Asked Questions

Can Excel shuffle rows randomly without a formula?
There is no standard one-click Shuffle command in Excel’s ribbon. The helper-column method uses a formula to create random sort keys; after converting those keys to values, you can sort the rows using Data > Sort.

How do I shuffle only some rows?
Select the intended records and all their related columns, then use a helper column and sort that selection. Check the selection carefully: rows outside it will not move, and a partial selection can separate fields that belong together.

Can I shuffle rows but keep the header at the top?
Yes. Include the header in the range you sort and indicate in the Sort dialog that the data has headers. Excel then sorts the records without treating the header as an ordinary row.

Will a shuffled order stay the same when I reopen the workbook?
A helper-column shuffle stays put if you convert the random keys to values before sorting. A formula-based shuffle can recalculate and change; paste its results as values if you need a fixed order.

Does shuffling rows change the data?
It changes row order, not the values in each record, provided the full data range is sorted together. A formula-generated shuffle displays a separate result and leaves the source range in place.

Related

Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.

More in How-to basics

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.