View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JE McGimpsey JE McGimpsey is offline
external usenet poster
 
Posts: 4,624
Default Generate Random Number Table

This will be fairly quick:

Public Sub FillNamedRangeWithRandoms()
Dim vArr As Variant
Dim i As Long
Dim j As Long
With Range("MyRange")
ReDim vArr(1 To .Rows.Count, 1 To .Columns.Count)
For i = 1 To UBound(vArr, 1)
For j = 1 To UBound(vArr, 2)
vArr(i, j) = Rnd
Next j
Next i
.Value = vArr
End With
End Sub


In article , Tim Bieri
wrote:

Howdy,

I would like to generate a random number in a named range. The named range
would have a variable size (up to 25000 row and 50 column). I know that I
can copy/paste RND() in all the cells, but I am interested in generating the
number. Using RND(), I would have to copy paste values so they would not
change. I am also concerned about looping that many times and how long that
would take.

Is there an easy way to essentially populate a 2-D array from a random
function?

Regards,
TB