View Single Post
  #7   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

Ok, I have it working now-

The reason I was getting the error was I had not yet redimmed my array to
truncate the last field (the one the contained the original text string, in
case I needed it later). The error was occuring when it tried to paste the
original strings into cells. Once I redimmed the array and shrank the paste
range accordingly, everything pasted just fine.

I know there is a visible character limit of something like 255 characters
in a cell, but I thought that the cell could actually hold a good bit more
than that. I'm now assuming that I hit an upper limit on the actual cell
string length, whatever that limit is.

Thanks again to Peter G and Peter T for the help,
Keith

"Keith R" wrote in message
...
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