Found This Macro and Function that pastes the data in column A1 to A100.
Is it possible to get it to paste the data in A1 to CV1.
I thought it was something to do with Application.Transpose but I cannot figure out how to change the macro to change the way it pastes the data
Is it possible to get it to paste the data in A1 to CV1.
I thought it was something to do with Application.Transpose but I cannot figure out how to change the macro to change the way it pastes the data
Code:
Function UniqueRandomNumbers(NumCount As Long, LLimit As Long, ULimit As Long) As Variant
' creates an array with NumCount unique long random numbers in the range LLimit - ULimit (including)
Dim RandColl As Collection, i As Long, varTemp() As Long
UniqueRandomNumbers = False
If NumCount < 1 Then Exit Function
If LLimit > ULimit Then Exit Function
If NumCount > (ULimit - LLimit + 1) Then Exit Function
Set RandColl = New Collection
Randomize
Do
On Error Resume Next
i = CLng(Rnd * (ULimit - LLimit) + LLimit)
RandColl.Add i, CStr(i)
On Error GoTo 0
Loop Until RandColl.Count = NumCount
ReDim varTemp(1 To NumCount)
For i = 1 To NumCount
varTemp(i) = RandColl(i)
Next i
Set RandColl = Nothing
UniqueRandomNumbers = varTemp
Erase varTemp
End Function
' example use:
Sub TestUniqueRandomNumbers()
Dim varrRandomNumberList As Variant
varrRandomNumberList = UniqueRandomNumbers(50, 1, 100)
Range(Cells(1, 1), Cells(50 + 2, 1)).Value = _
Application.Transpose(varrRandomNumberList)
End Sub
Last edited: