View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
goaljohnbill goaljohnbill is offline
external usenet poster
 
Posts: 18
Default Putting large array into a worksheet

I have a program creating an array using Chip Pearsons excellent
UniqueRandomLongs function. I found some other code in here that will
put it in a worksheet in 1 column. This method seems to have a max of
256 items (# of columns in excel I suppose). I would like to be able
to do more than that if possible. Could anyone help me out? The
current code Im using for placement is:

Dim Res As Variant
Dim Min As Long
Dim Max As Long
Dim N As Long

'''''''''''''''''''''''''''''
' Get N non-duplicated Longs
' each of which is between
' 1 and Max.
'''''''''''''''''''''''''''''
Min = 1
Max = reccount
N = recpct

Res = UniqueRandomLongs(Minimum:=Min, Maximum:=Max, Number:=N)

If IsArrayAllocated(Res) = False Then
Debug.Print "Error from UniqueRandomLongs."
Else
arr = Res
m = UBound(arr, 1) - LBound(arr, 1) + 1
Set targetrng = Range("A2").Resize(, m)
targetrng.Value = arr
Range("A2:A" & m).Value = Application.Transpose(arr)

End If