Generate Two Random Numbers That Sum to a Fixed Value in Excel
Question details
Create two random values in B1 and B2 that always add up to the value in A1.

- 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.
Enter the desired total in cell A1. For a nonnegative whole-number split, make sure A1 contains a nonnegative integer.
Generate two random decimal values
Use RAND to split the total into two decimal values.
Select B1, enter =RAND()*$A$1, and press Enter.
Select B2, enter =$A$1-B1, and press Enter. The two cells will add up to A1.
Select B1:B2, copy the cells, and use Paste Special > Values to replace both formulas with their current results.

Generate two random whole numbers
Use RANDBETWEEN when both parts must be nonnegative integers.
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. Enter the total: Open WPS Spreadsheets and enter the fixed total in A1.
- 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. Calculate the second value: In B2, enter =$A$1-B1. The values in B1 and B2 will add up to A1.
- 4. Keep the current values: To prevent further changes, copy B1:B2 and use Paste Special > Values to replace the formulas.

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.




