I am running the below algorithm on an array of 100k items (I would like to expand it to 1m if possible) and am facing performance issues. I would like to reduce the processing time down to a few seconds. I am pretty sure the first loop is causing the code to slow down. Is it possible to automatically shuffle the array 250 times, to populate a matrix and then simply paste it? - instead of going through 250 separate connections between vba and excel.
For a = 0 To 249
For i = UBound(myArray , 1) To 1& Step -1&
NewRow= Int(Rnd() * i) + 1&
temp = myArray (i, 1)
myArray (i, 1) = myArray (NewRow, 1)
myArray(NewRow, 1) = temp
Next i
Range(Cells(1, a + 1), Cells(LastRow, a + 1)).Value = myArray
Next a
any help is appreciated!! Thanks! John