```
Dim Total as Double, Rand1 as Double, Rand2 as Double, Rand3 as Double, Rand4 as Double
Dim factor as D
Total = 21
Rand1 = Rnd()
Rand2 = Rnd()
Rand3 = Rnd()
Rand4 = Rnd()
factor = Total / (Rand1 + Rand2 +Rand3 +Rand4)
Rand1 = factor * Rand1
Rand2 = factor * Rand2
Rand3 = factor * Rand3
Rand4 = factor * Rand4
Rand1 = WorksheetFunction.Round(Rand1, 0)
Rand2 = WorksheetFunction.Round(Rand2, 0)
Rand3 = WorksheetFunction.Round(Rand3, 0)
Rand4 = Total - Rand1 - Rand2 -Rand3
MsgBox "Four numbers " & Rand1 & Rand2 & Rand3 & Rand4 & "total " & Total
```