Creating Random Data With RANDARRAY
Produce arrays of random numbers for samples and testing.
Creating Random Data With RANDARRAY is a free Excel Formulas Academy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Excel Formulas Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
What RANDARRAY Does
Need a block of random numbers for testing, sampling, or a quick simulation? The RANDARRAY function generates an entire array of random values from one formula.
Older spreadsheets had RAND (one random decimal) and RANDBETWEEN (one random integer). RANDARRAY rolls both ideas into a single spill function that fills as many cells as you ask for.
=RANDARRAY(5, 1)The RANDARRAY Syntax
RANDARRAY accepts up to five arguments, all optional:
- rows how many rows to fill (default 1)
- columns how many columns (default 1)
- min the smallest value (default 0)
- max the largest value (default 1)
- whole_number TRUE for integers, FALSE for decimals (default FALSE)
With no arguments at all, it returns a single random decimal between 0 and 1.
=RANDARRAY(rows, [columns], [min], [max], [whole_number])A Column of Random Decimals
The simplest useful call asks for several rows of decimals between 0 and 1. Each value is a fresh random number with many decimal places.
This formula spills 10 random decimals down a column, handy for weighting, jitter, or probability tests.
=RANDARRAY(10)Setting a Min and Max
The third and fourth arguments set the range of values. To get decimals between 50 and 100, supply those as min and max.
Remember to include rows and columns first. This gives 8 random decimal values, each somewhere between 50 and 100.
=RANDARRAY(8, 1, 50, 100)Generating Whole Numbers
Set the fifth argument whole_number to TRUE to get integers instead of decimals. This is the modern replacement for RANDBETWEEN.
This formula produces 6 random whole numbers from 1 to 6, like rolling a handful of dice.
=RANDARRAY(6, 1, 1, 6, TRUE)Building a Random Grid
Provide both rows and columns to fill a rectangular block. Combine that with min, max, and TRUE for a grid of integers.
Here we make a 4-row, 3-column grid of whole numbers from 1 to 100, perfect for sample datasets or test fixtures.
=RANDARRAY(4, 3, 1, 100, TRUE)RANDARRAY Recalculates
RANDARRAY is volatile: its values change every time the sheet recalculates, such as when you edit any cell or press F9. That is great for live what-if testing but bad if you need stable numbers.
If you want to freeze a set of random values, copy the spilled range and paste it back as values only.
=RANDARRAY(10, 1, 1, 100, TRUE)Random Sampling With SORTBY
A neat trick: shuffle a list into random order by sorting it with RANDARRAY as the key. Pair it with SORTBY.
For names in A2:A20, this orders them by a fresh random number, effectively shuffling the list. Take the top few rows for a random sample.
=SORTBY(A2:A20, RANDARRAY(19))RANDARRAY in Google Sheets
Google Sheets supports RANDARRAY too, though its argument set is simpler: just rows and columns, always returning decimals between 0 and 1.
To get a custom range or integers in Sheets, wrap the result, for example multiply and add, then use INT. Excel's min, max, and whole_number arguments are not available there.
=INT(RANDARRAY(6,1)*6)+1Mind the Spill
Like every dynamic array, RANDARRAY needs empty cells to expand into. A large request such as RANDARRAY(1000) will throw #SPILL! if anything blocks the range.
Place it in open space and clear obstructions before generating big blocks of random data.
=RANDARRAY(1000, 1, 1, 100, TRUE)A Practical Test Dataset
Combine ideas to mock up data fast. Generate a column of random sales figures to test a dashboard before the real numbers arrive.
This spills 50 random whole-dollar amounts between 100 and 5000. Paste as values to lock them, then build your formulas on top.
=RANDARRAY(50, 1, 100, 5000, TRUE)Quick Check
You want a single column of 6 random whole numbers between 1 and 6, like dice rolls. Which formula is correct?
Recap: Random Data With RANDARRAY
RANDARRAY fills a block with random values from one formula:
=RANDARRAY(rows, columns, min, max, whole_number)- All arguments are optional; bare RANDARRAY() gives one decimal 0 to 1
- Set whole_number to TRUE for integers (replaces RANDBETWEEN)
- It is volatile, so paste as values to freeze the numbers
Pair it with SORTBY to shuffle and sample, and leave room for the spill.
=RANDARRAY(6, 1, 1, 6, TRUE)Frequently asked questions
Is the “Creating Random Data With RANDARRAY” lesson free?
Yes — the full text of “Creating Random Data With RANDARRAY” is free to read here on the web, and the Excel Formulas Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Excel Formulas Academy course, upgrade to CoddyKit PRO.
What will I learn in “Creating Random Data With RANDARRAY”?
Produce arrays of random numbers for samples and testing. You practise Excel Formulas Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Excel Formulas Academy?
No prior experience is required. Excel Formulas Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Creating Random Data With RANDARRAY” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Excel Formulas Academy lesson?
Yes. Every Excel Formulas Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Ordering Results With SORT
- Sorting by Another Column With SORTBY
- Generating Numbers With SEQUENCE
- Creating Random Data With RANDARRAY