View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Karin[_2_] Karin[_2_] is offline
external usenet poster
 
Posts: 2
Default random integer with sum constraint

Hi

I want to generate two random integers that fall within a certain range
("min" to "max", e.g. 0 to 10) AND that sum to equal no more than a given
value ("maxsum", e.g. 19)

The first integer is easy (using a Analysis Toolpak add-in)
A1=RANDBETWEEN(min, max)

But that second integer has me stuck. I started with A2=RANDBETWEEN(min,
maxsum-A1) but then a lot of the results were larger than "max." Oops. Any
ideas on what else I need to put in there?

Thanks,
Karin