Fix Excel SEQUENCE and RANDBETWEEN Spill Error
Question details
The user needs to resolve intermittent #SPILL! errors caused by combining the SEQUENCE and RANDBETWEEN functions.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Generating dynamic data arrays where the rows, columns, start, or step inputs rely on random variables.
- Observed behavior
- The formula produces #SPILL! errors because independent recalculations of RANDBETWEEN alter the array size dynamically, causing destination range conflicts during evaluation.
Verify that the intended destination range for your array is completely empty, as any existing data, spaces, or merged cells will block the expansion and trigger a spill error.
Use the LET Function to Lock Random Values
The LET function calculates the random values once and stores them as variables, preventing the array size from changing inconsistently during a single calculation cycle.
Because RANDBETWEEN is a volatile function, using it multiple times inside SEQUENCE causes independent recalculations. Wrapping the formula in a LET function establishes a single, fixed random value for the duration of that specific formula execution.
Select an empty cell and begin your formula by typing =LET(randRows, RANDBETWEEN(1, 10), to define your random row variable.
Complete the formula by calling the locked variable inside SEQUENCE. Your final formula should look like: =LET(randRows, RANDBETWEEN(1, 10), SEQUENCE(randRows)).
Press Enter to execute. The array will generate and spill downwards based on the locked random number without resizing erratically.

Store Random Variables in Separate Helper Cells
By calculating RANDBETWEEN in isolated cells, you force the spreadsheet to evaluate the random numbers before passing them to the SEQUENCE formula.
Master Dynamic Arrays with WPS Spreadsheets
WPS Spreadsheets fully supports modern dynamic array functions like SEQUENCE, RANDBETWEEN, and LET. You can effortlessly build complex, error-free array formulas with an intuitive interface and high processing speed.
- 1. Open WPS Spreadsheets: Launch WPS Office on your device and create a new blank spreadsheet.
- 2. Input the LET formula: Click on an empty cell and enter your optimized formula: =LET(r, RANDBETWEEN(1,5), SEQUENCE(r)).
- 3. Generate the array: Press Enter to instantly generate your dynamic array without encountering recalculation spill conflicts.

Frequently Asked Questions
What exactly does a #SPILL! error mean in spreadsheets?
A #SPILL! error indicates that a dynamic array formula needs to output multiple values into adjacent cells, but one or more of those destination cells are currently occupied by data, spaces, or formatting.
Why is RANDBETWEEN considered a volatile function?
RANDBETWEEN is volatile because it triggers a recalculation every single time any change or input is made anywhere in the worksheet, which can cause dynamic arrays attached to it to constantly resize and stutter.
Can I use the SEQUENCE function in older spreadsheet versions?
Dynamic array functions like SEQUENCE and LET are only supported in modern spreadsheet applications (such as Microsoft 365, Office 2021, and updated versions of WPS Office). Older versions will return a #NAME? error.




