Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

How to Do Random in Excel: RAND, RANDBETWEEN and More

· 7 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Excel can generate random numbers, pick random names, shuffle a list or draw a random sample using two built-in functions: RAND() returns a decimal between 0 and 1, and RANDBETWEEN(bottom, top) returns a whole number inside a range you set. Type =RANDBETWEEN(1,100) into any cell and press Enter to get a random integer from 1 to 100. That one line is the shortest answer; the rest of this guide covers picking names, shuffling, sampling and, most importantly, stopping Excel from reshuffling everything every time you touch a cell.

What You'll Need

  • A desktop copy of Excel (Microsoft 365, Excel 2021, 2019 or 2016). RAND and RANDBETWEEN work on all of them.
  • Excel for the web for basic use. RANDARRAY and dynamic arrays need a Microsoft 365 build; older versions will reject them.
  • A saved workbook. Random functions recalculate on every edit, so save before you start if you want to keep a copy of previous results.
  • Optional: a list of names, items or rows you want to pick from.

Step-by-Step

  1. Generate a random decimal. Click an empty cell, type =RAND() and press Enter. You get a value like 0.7413. The brackets matter even though there is nothing inside them. To fill a block of cells, type the formula once and drag the fill handle down or across; each cell gets its own independent number.
  2. Generate a random whole number. Use =RANDBETWEEN(1,10) for 1 to 10 inclusive, or =RANDBETWEEN(50,500) for a wider range. Both limits are included in the possible results, so RANDBETWEEN(1,10) really can return 1 and really can return 10.
  3. Generate a number with decimals in a custom range. There is no direct function for this; multiply RAND by the width of your range and add the lower bound. For a random price between 10 and 25, use =RAND()*(25-10)+10. Wrap it in ROUND to control the decimals, for example =ROUND(RAND()*15+10,2) for two decimal places.
  4. Pick a random item from a list. Put your list in a column, say A2:A20. In another cell use =INDEX(A2:A20,RANDBETWEEN(1,COUNTA(A2:A20))). COUNTA counts how many entries the list has, RANDBETWEEN picks a position, and INDEX fetches the entry at that position. This handles lists that grow without you editing the formula.
  5. Pick a random name without repetition. Random picks can repeat the same person. For a one-off draw, add a helper column next to your list, put =RAND() in each row, then sort the whole table by that helper column. Read names from the top: the first rows become your random selection with no duplicates.
  6. Shuffle a whole list. This is the same trick done deliberately. Add a RAND column beside your data, select the entire table including the helper column, then use Data tab > Sort and choose the RAND column. Every sort reorders the rows randomly while keeping each row's data together. Delete the helper column afterwards.
  7. Draw a random sample of a set size. Shuffle as above, then take the first N rows, for example the first 10 of 200. Sorting by a RAND column and cutting the top rows is the standard sampling method in Excel and is easier to audit than nested formulas.
  8. Generate a block of random values in one go (Microsoft 365 only). Use =RANDARRAY(5,3,1,100,TRUE) to fill 5 rows by 3 columns with whole numbers from 1 to 100. The arguments are rows, columns, minimum, maximum and whether to return whole numbers (TRUE) or decimals (FALSE). On older Excel versions this spills a #NAME? error; use RAND or RANDBETWEEN in individual cells instead.
  9. Freeze the results. Random functions recalculate whenever the sheet recalculates, so your numbers change on nearly every edit. To lock them, select the cells, copy with Ctrl+C, then paste back as values using Paste Special > Values, or right-click and choose Paste Options > Values. Keyboard shortcut: Ctrl+Alt+V then V then Enter. The formulas are replaced by fixed numbers and stop moving.
  10. Force a recalculation if you want a new draw. Press F9 to recalculate the whole workbook, or Shift+F9 for just the active sheet, and every random formula produces fresh values.
  11. Stop automatic recalculation entirely. If you want the numbers to stay put while you work, go to Formulas tab > Calculation Options and choose Manual. Note the literal labels can differ slightly by Excel version, so look for the calculation options in the Formulas ribbon. Set it back to Automatic when you are done, or dependent formulas will show stale results.

Common Mistakes

  • Forgetting that RAND changes constantly. The most frequent complaint is "my random numbers keep changing". That is correct behaviour, not a bug. Paste as values when you need a fixed set.
  • Writing RAND without brackets. =RAND may be accepted but is not the reliable form. Always type =RAND().
  • Assuming RANDBETWEEN excludes the top number. It includes both limits. RANDBETWEEN(1,6) behaves like a fair die with six possible outcomes, not five.
  • Sorting only part of the table. If you sort the RAND column alone, the numbers shuffle but the names beside them stay in place, wrecking the pairing. Always select the whole data range, or use Data > Sort and tick the box confirming the range has headers.
  • Using drag-fill on a fixed formula. Dragging =RANDBETWEEN(1,10) gives each cell its own result and that is fine, but copying a formula containing mixed references can lock values you did not mean to lock. Check a couple of cells after filling.
  • Expecting RANDARRAY in older files. If you open a workbook using RANDARRAY in Excel 2016, the formula shows an error because the function does not exist there. Keep such workbooks in Microsoft 365.
  • Trusting random numbers for security. Excel's random functions are for simulations, games and sampling. They are not cryptographic and must never be used to generate passwords, PINs, tokens or anything security-related.

Tips

  • Keep a permanent "master" copy of your list and do shuffling on a duplicate sheet; it is easy to overwrite source data accidentally.
  • Use a named range for your list so formulas read as =INDEX(Employees,RANDBETWEEN(1,COUNTA(Employees))) and survive row insertions.
  • For a weighted pick, build a cumulative weight column and compare it against RAND(), rather than repeating list entries manually.
  • To simulate dice, coins or a lottery draw quickly, RANDBETWEEN(1,6) is your die, =RANDBETWEEN(0,1) works as a coin flip (0 and 1), and shuffling is your draw without replacement.
  • If you need repeatable "random" results for a demonstration, just paste values once and reuse that frozen set.
  • Combine ROUND or INT with your formula so results do not carry long unwanted decimals into reports.

Troubleshooting

  • Numbers change every time you type elsewhere. Expected. Paste as values as described in step 9, or switch calculation to Manual while you build the sheet.
  • You see #NAME? next to a formula. Either the function is not available in your Excel version (usually RANDARRAY or another dynamic array function) or the function name is misspelled. Check your version and use RAND or RANDBETWEEN instead.
  • You see #VALUE! in RANDBETWEEN. One of the limits is text or a cell that looks like a number but is stored as text. Retype the values or use VALUE() to convert them.
  • INDEX returns the wrong name. Your range probably starts below the first entry, or COUNTA is counting a header row. Shrink the range to the actual data.
  • The list sort scrambles your names. You sorted a single column rather than the full table. Undo with Ctrl+Z, then reselect the entire table including the RAND helper column before sorting.
  • RANDARRAY spills over existing data. You get a #SPILL! error. Clear the cells the result needs, or reduce the rows and columns so the block fits.

Frequently Asked Questions

Does RAND ever return exactly 0 or 1?

RAND returns a value greater than or equal to 0 and less than 1, so 0 is technically possible and 1 is not. In practice both are extremely unlikely.

How do I get random numbers that never repeat?

Random functions can repeat. For a set of distinct numbers, use the shuffle method: add a RAND column, sort by it, and take the top rows. That guarantees no duplicates within your selection.

Why did my random names all change after I fixed a typo?

Because RAND and RANDBETWEEN recalculate when the sheet recalculates. Fix the results by pasting them as values before you continue editing.

Can I use these functions in Google Sheets?

Yes. Google Sheets has the same RAND and RANDBETWEEN functions with identical syntax, and it also offers RANDARRAY, so the formulas in this guide carry over.

Is Excel randomness good enough for simulations?

Yes for typical simulations, games and sampling. It is not suitable for security, encryption or gambling systems that require unpredictable, tamper-proof numbers.

How do I re-roll a single random cell?

Press F9 to recalculate the workbook, or Shift+F9 for the current sheet. If calculation is set to Manual, press F9 to force one recalculation. To keep the old value, copy the cell and paste it back as a value first.