title: Random Number Generation to Memory from a Distribution using VBA
body: <p>I want to generate random numbers from a selected distribution in VBA (Excel 2007).
  I'm currently using the Analysis Toolpak with the following code:</p>
  
  <pre><code>     Application.Run "ATPVBAEN.XLAM!Random", "", A, B, C, D, E, F
  </code></pre>
  
  <p>Where</p>
  
  <pre><code>A = how many variables that are to be randomly generated 
  B = number of random numbers generated per variable 
  C = number corresponding to a distribution
           1= Uniform
           2= Normal
           3= Bernoulli
           4= Binomial
           5= Poisson
           6= Patterned
           7= Discrete 
  D = random number seed
  E = parameter of distribution (mu, lambda, etc.) depends on choice for C
  (F) = additional parameter of distribution (sigma, etc.) depends on choice for C
  </code></pre>
  
  <p>But I want to have the random numbers be generated into an array, and NOT onto a sheet.
  I understand that where the <code>""</code> is designates where the random numbers should be printed to, but I don't know the syntax for assigning the random numbers to an array, or some other form of memory storage instead of to a sheet.</p>
  
  <p>I've tried following the syntax discussed at this <a href="http://www.cpearson.com/excel/atp.htm" rel="nofollow noreferrer">Analysis Toolpak site</a>, but have had no success.</p>
  
  <p>I realize that VBA is not the ideal place to generate random numbers, but I need to do this in VBA. Any help is much appreciated! Thanks!</p>