ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel: Array & Memory (https://www.excelbanter.com/excel-programming/275811-excel-array-memory.html)

EG[_2_]

Excel: Array & Memory
 
hi,

i got the fct below from Microsoft (this is to copy/paste
data from an ADODB recordset to Excel sheet).
Thing is that memory usage keeps growing each time I use
the function till the fatal msg "Not enough memory
available..."
I think this has to do with memory not being released once
the array has been used.
The 'Erase' doesn't work, the 'Nothing' either...

Tks to help,
Eric/


Function fct_TransposeDim(v As Variant) As Variant
' Custom Function to Transpose a 0-based array (v)

Dim X As Long, Y As Long, Xupper As Long, Yupper As
Long
Dim tempArray As Variant

Xupper = UBound(v, 2)
Yupper = UBound(v, 1)

ReDim tempArray(Xupper, Yupper)
For X = 0 To Xupper
For Y = 0 To Yupper
tempArray(X, Y) = v(Y, X)
Next Y
Next X

fct_TransposeDim = tempArray

Erase tempArray
'tempArray = Nothing

End Function


All times are GMT +1. The time now is 09:54 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com