View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Keith R Keith R is offline
external usenet poster
 
Posts: 55
Default load/parse large text file

Peter- I apologize for being so dense- I've not taken this approach before,
so the syntax is killing me. I switched the rows and columns, so that part
is done.

I believe the Ubound and LBound would need to refer to the array, so
therefore 'a' has to refer to my array. I changed the line a=selection to
a=myarray()

It gets through the Ubound/LBound lines and returns correct size paramters,
but when it tries to assign the array to my worksheet, I get a runtime error
1004 application- or object-defined error.

Sheet17.Range("a1").Resize(r, c) = a
values=
Sheet17.range("a1").Resize(5000,32)=a
I also reversed it in case the resize was based on my original (switched)
array order
Sheet17.range("a1").resize(32,5000)=a
but got the same error.

I tried both a=myarray() and a=myarray

Thank you for your continued help and patience,
Keith


"Peter Grebenik" wrote in message
oups.com...
Keith

I think that you need to swap your rows and columns so that it becomes
testArray(rows,columns).

To put your array into the sheet, you need to set the range size to be
equal to the array size as the following sample code shows. I used
this to copy a range of 40000 rows by 31 columns in about 10 seconds.

Sub t()
Dim r As Long, c As Long, a As Variant
a = Selection

r = UBound(a, 1) - LBound(a, 1) + 1
c = UBound(a, 2) - LBound(a, 2) + 1

Range("ah2").Resize(r, c) = a

End Sub


Peter