View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Out of Memory: Array Transpose

What do you gain by transposing an array of that size. I can't see anything
you could do with it as an "entity". So if you only need to reference
values in it, just reverse your thinking and transpose your indexes.

--
Regards,
Tom Ogilvy

"TheVisionThing" wrote in message
...
I'm using the following function to transpose a 2d array in Excel 2003.

Public Function TransposeArray(arrIn As Variant)
Dim i As Long, j As Long, lngUpperI As Long, lngUpperJ As Long,
intLoweri As Integer, intLowerj As Integer, arrOut() As Variant
lngUpperI = UBound(arrIn, 1)
lngUpperJ = UBound(arrIn, 2)
intLoweri = LBound(arrIn, 1)
intLowerj = LBound(arrIn, 2)
ReDim arrOut(intLowerj To lngUpperJ, intLoweri To lngUpperI)
For i = intLoweri To lngUpperI
For j = intLowerj To lngUpperJ
arrOut(j, i) = arrIn(i, j)
Next
Next
Set arrIn = Nothing
TransposeArray = arrOut
End Function

The function usually works fine, but it generates an out of memory error
message on a 190,000 by 4 2d array. I presume that is because the

function
is creating a new array, arrOut, that's as big as the incoming array,

arrIn.

Does anyone know how to break down such a function into digestible bits,

so
that it doesn't run out of memory? The worksheet function
Application.Transpose is not an option, as it generates an error message
after about 64,000 rows.

Thanks,
Wayne C.