Excel: Array & Memory

E

EG

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top