View Single Post
 
Old 11-18-2014, 05:34 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,365
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

One possibility:
In A1 =INT(RANDBETWEEN(80,600))
In A2 =INT(RANDBETWEEN(80,MIN(600,(A$76-SUM(A$1:A1))/COUNT(A1,A$76))))
Copy A2 down to A74
In A75 =A76-SUM(A1:A74)
In A76 20000

Pressing F9 will eventually get a series of numbers in rows 1-75 that total the 20000. You might have to press F9 many times to fill all numbers. Or you could use a macro to do the re-calcs for you:
Code:
Sub Recalc()
Application.Calculate
While Range("A75").Text = "#NUM!"
  Application.Calculate
Wend
End Sub
The final number may sometimes be outside the upper & lower bounds (i.e. 80 & 600). You can prevent that by using:
While Range("A75").Text = "#NUM!" Or Range("A75").Text < 80 Or Range("A75").Text > 600
instead of:
While Range("A75").Text = "#NUM!"
This change means it will likely take Excel more iterations (i.e. longer) to return a result. Likewise, the larger you make the '600' in the formulae (and macro), the longer it will take Excel to return a result. Conversely, making the 80 smaller will reduce the time it will take Excel to return a result.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote