Hi all
Code below runs ok most of the time.
Only sometimes i get a run-time error 1004: Unable to get the loginv property of the worksheetfunctions class.
Would you know why and how to fix/workaround it?
Thank you.
Best, zurich



Sub VBA_short()
*
Dim D1, D2 As Date***
Dim tempoimpiegato As String*
D1 = Time**
*
*** Dim myarray As Variant
*** Dim myarraysev(1000000#) As Variant
*** Dim bigArray(1000000#) As Variant
*** Dim sum As Double
*** Dim smallarray(1 To 50000, 2) As Variant
******
*** Dim x As Long, j As Long, n As Long, i As Long
*******
*** myarray = Worksheets("Sheet1").Range("A1:cv20000").Value
*
*** ****For x = 1 To 20000
*
******* For j = 1 To 50
*
sum = 0
***********************************
*********** *********** For n = 1 To myarray(x, j)
***********
*********** *********** myarraysev(n) = Application.WorksheetFunction.LogInv(Rnd(), 6.2146, 1.3204)
**************************************************
*********** *********** sum = myarraysev(n) + sum
*****************************************************
*********** *********** Next n
***********
*********** i = i + 1
*******************************
********** bigArray(i) = sum
***********
******* Next j
*
*** Next x
***
*
For col = 1 To 25
*
smallcounter = 1
*
For i = 1 + ((col - 1) * 50000) To col * 50000
*
smallarray(smallcounter, 0) = i
*
smallarray(smallcounter, 1) = bigArray(i)
*
smallcounter = smallcounter + 1
*
Next i
*
Range("hhhh").Resize(50000, 2).Offset(0, (col - 1) * 3).Value = smallarray
*
Next col
*
D2 = Time
*
tempoimpiegato = Format(D2 - D1, "hh:mm:ss")
*
MsgBox "Tempo impiegato: " & tempoimpiegato**
*
End Sub