WeCodeAcademy

RAND and RANDBETWEEN

RAND() returns a random decimal between 0 and 1; RANDBETWEEN(low, high) a random whole number in a range. They are handy for sample data, simulations and shuffling a list.

They are volatile: every time the sheet recalculates they give new numbers. To keep a set, copy the cells and Paste Special as values. Press Run on the example a few times and the numbers change.

Exampleexcel
Open in editor »
Quick check

What happens to RAND() each time the sheet recalculates?

Your turn: write the code

RAND() is always below 1. Use ROUNDDOWN(RAND(),0) in A1 (the result is always the same).

Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.

Tip: use the left and right arrow keys to move between lessons.