Calculation Issues

Generate 125 Random Numbers With a Fixed Sum in Excel

Khadija KhanKhadija Khan Nov 18, 2026 870 views

Question details

Generate 125 random values between 1.1 and 2.1 with a total of 245.

Generate 125 Random Numbers With a Fixed Sum in Excel
Product
Microsoft Excel and WPS Spreadsheets
Device & OS
not provided
Scenario
A spreadsheet needs a set of random values that meets both individual limits and a fixed total.
Observed behavior
The desired values must average 1.96, so many will need to be close to the upper limit of 2.1.
Before you start

Open a blank worksheet and make sure cells B1:C126 are available. The target is feasible because 125 × 1.1 ≤ 245 ≤ 125 × 2.1.

Solution 1Recommended

Generate Values Sequentially Using Feasible Bounds

Use this method in Excel or WPS Spreadsheets to keep enough of the remaining total available for every subsequent value.

Each formula chooses a random value within the range that still allows the remaining positions to reach the target. This sequential method does not sample all valid sets uniformly, and earlier values can affect later values.

1
Enter the target

Type 245 in cell C1. This cell holds the starting amount remaining.

2
Calculate the first value

Enter this formula in B2: =MAX(1.1,C1-(126-ROW())*2.1)+RAND()*(MIN(2.1,C1-(126-ROW())*1.1)-MAX(1.1,C1-(126-ROW())*2.1))

3
Track the remaining total

Enter =C1-B2 in C2. This subtracts the generated value from the amount remaining.

4
Fill the formulas down

Select B2:C2 and drag the fill handle down through row 126. Cells B2:B126 now contain 125 values.

5
Check the results

In empty cells, enter =SUM(B2:B126), =MIN(B2:B126), and =MAX(B2:B126). The sum should be 245, subject to spreadsheet floating-point precision.

Generate Values Sequentially Using Feasible Bounds
Recalculation and precision: RAND recalculates when the worksheet recalculates. Floating-point arithmetic can produce tiny rounding differences; rounding individual displayed values can also make their displayed total differ from 245.
WPS Spreadsheets

Generate a Fixed-Sum Random List in WPS Spreadsheets

Use RAND and a running remainder in WPS Spreadsheets to create 125 bounded random values that add up to the target.

  1. 1. Set the target: Open a blank sheet in WPS Spreadsheets and enter 245 in C1.
  2. 2. Enter the random formula: In B2, enter =MAX(1.1,C1-(126-ROW())*2.1)+RAND()*(MIN(2.1,C1-(126-ROW())*1.1)-MAX(1.1,C1-(126-ROW())*2.1)).
  3. 3. Calculate the remainder: In C2, enter =C1-B2, then select B2:C2 and drag the fill handle through row 126.
  4. 4. Verify the list: Use =COUNT(B2:B126) and =SUM(B2:B126) in empty cells to check the 125 values and their total.
Generate values within bounds while tracking the remaining totalCheck the count, sum, minimum, and maximum with spreadsheet formulasOpen and save Microsoft Excel XLSX filesUse a familiar spreadsheet interface for free
microsoft office alternative - wps office

Frequently Asked Questions

Why does RAND alone not produce a total of 245?

A formula such as =1.1+RAND() calculates each value independently, so the total is not constrained. The sequential formula limits each choice based on the remaining target and number of values.

How can I keep the generated values from changing?

Select B2:B126, copy the cells, and use Paste Special > Values to replace the formulas with their current results. Copy the values before recalculating the worksheet.

Why do the displayed values sometimes not add up to exactly 245?

The spreadsheet stores numbers with finite precision, and formatting can round each displayed value. Check =SUM(B2:B126) and increase the displayed decimal places to inspect the result.

Will every valid set of 125 values be equally likely?

No. The sequential method chooses each value from its current feasible range, so the order of the choices affects the distribution. A uniform sample of valid sets requires a different sampling method.