Function Problems

Generate Two Random Numbers That Sum to a Fixed Value in Excel

Huda QurayshiHuda Qurayshi Dec 2, 2026 869 views

Question details

Create two random values in B1 and B2 that always add up to the value in A1.

Generate Two Random Numbers That Sum to a Fixed Value in Excel
Product
Microsoft Excel
Device & OS
not provided
Scenario
Split a fixed spreadsheet value into two random decimal or whole-number parts.
Observed behavior
The values in B1 and B2 should total the value entered in A1.
Before you start

Enter the desired total in cell A1. For a nonnegative whole-number split, make sure A1 contains a nonnegative integer.

Solution 1Recommended

Generate two random decimal values

Use RAND to split the total into two decimal values.

1
Generate the first value

Select B1, enter =RAND()*$A$1, and press Enter.

2
Calculate the second value

Select B2, enter =$A$1-B1, and press Enter. The two cells will add up to A1.

3
Keep a result if needed

Select B1:B2, copy the cells, and use Paste Special > Values to replace both formulas with their current results.

Generate two random decimal values
Results recalculate: RAND generates a new value whenever Excel recalculates. Pasting both cells as values keeps the current split.
Random number formulas in WPS

Create a random fixed-sum split in WPS Spreadsheets

Use RAND or RANDBETWEEN in WPS Spreadsheets to generate one random part, then subtract it from the total to calculate the other.

  1. 1. Enter the total: Open WPS Spreadsheets and enter the fixed total in A1.
  2. 2. Create a random value: In B1, enter =RAND()*$A$1 for a decimal split, or =RANDBETWEEN(0,$A$1) for a nonnegative whole-number split. For the latter, A1 must contain a nonnegative integer.
  3. 3. Calculate the second value: In B2, enter =$A$1-B1. The values in B1 and B2 will add up to A1.
  4. 4. Keep the current values: To prevent further changes, copy B1:B2 and use Paste Special > Values to replace the formulas.
Split a fixed total into random decimal or whole-number valuesOpen and edit Microsoft Excel XLSX and XLS filesUse familiar spreadsheet formulas and cell referencesKeep a generated split by pasting the results as values
microsoft office alternative - wps office

Frequently Asked Questions

Why do the random numbers change?

RAND and RANDBETWEEN generate new results when the workbook recalculates. To keep a split, copy B1:B2 and use Paste Special > Values.

How do I generate two whole numbers that add up to A1?

Enter a nonnegative integer in A1, use =RANDBETWEEN(0,$A$1) in B1, and enter =$A$1-B1 in B2.

Can either random whole number be zero?

Yes. RANDBETWEEN(0,$A$1) includes both endpoints, so B1 or B2 can be zero.

Why might the displayed decimals appear not to add up exactly?

Cell formatting can round each displayed value separately. Increase the displayed decimal places or check the underlying values; B2 is calculated as A1 minus B1.