I have a spreadsheet where i create 4-5 fairly large matrices in worksheet cells and then perform some further calculation using these.
I'd like to update the spreadsheet to not use worksheet cells and to hopefully run faster.
I've started to do this using 2D Arrays to store my data in reference it in later calculations, however this is running pretty slow (may even be slower than v1 using worksheets cells). Here is an example of one of my arrays.
'Corr Matrix Array
ReDim CorrArr(1 To c, 1 To c) As Variant
For i = LBound(CorrArr, 1) To UBound(CorrArr, 1)
For j = LBound(CorrArr, 2) To UBound(CorrArr, 2)
CorrArr(i, j) = WorksheetFunction.Correl(ws1.Range(ws1.Cells(i + 1, 7), ws1.Cells(i + 1, LastCol1)), ws1.Range(ws1.Cells(j + 1, 7), ws1.Cells(j + 1, LastCol1)))
Next
Next
My guess is it is really being slowed down by having to loop through each element of the matrix (which is 1000 x 1000).
Is there a way to create arrays or store data without having to loop through each element?
Thanks
I'd like to update the spreadsheet to not use worksheet cells and to hopefully run faster.
I've started to do this using 2D Arrays to store my data in reference it in later calculations, however this is running pretty slow (may even be slower than v1 using worksheets cells). Here is an example of one of my arrays.
'Corr Matrix Array
ReDim CorrArr(1 To c, 1 To c) As Variant
For i = LBound(CorrArr, 1) To UBound(CorrArr, 1)
For j = LBound(CorrArr, 2) To UBound(CorrArr, 2)
CorrArr(i, j) = WorksheetFunction.Correl(ws1.Range(ws1.Cells(i + 1, 7), ws1.Cells(i + 1, LastCol1)), ws1.Range(ws1.Cells(j + 1, 7), ws1.Cells(j + 1, LastCol1)))
Next
Next
My guess is it is really being slowed down by having to loop through each element of the matrix (which is 1000 x 1000).
Is there a way to create arrays or store data without having to loop through each element?
Thanks