PDA

View Full Version : Text Import Code crashes at same record



Glaswegian
04-12-2011, 02:44 AM
Hi

I'm using Chip Pearson's ImportBigFiles code but the code keeps crashing on one particular line. I've used Chip's code many times over the years and never had a problem.

The test file does contain around 2 million records but there are only 6 columns of data. The data looks like this

00000056855372;AM;0002;00000081288515; ;0419

and this is the line that crashes - it's always record number 1,047,937. I even deleted the above line from the text file but the code still crashes - on the same line number.

These are the code lines

If Colndx + C_START_COLUMN <= WS.Columns.Count Then
WS.Cells(RowNdx, Colndx + C_START_COLUMN).Value = Arr(Colndx)
Else
The red line is where the code stops.

Looking at the workbook there are only 18 sheets created when the code stops so I don't believe this is the problem.

Has anyone run into this problem before? Could it be an Excel memory issue perhaps? I've closed all other applications but it makes no difference.

Any suggestions most welcome.

Thanks.

shrivallabha
04-12-2011, 09:13 PM
This perhaps is the crudest way:
If you suspect memory issue then perhaps the below method will probably give you the quickest pointer:
http://www.tek-tips.com/viewthread.cfm?qid=1158856&page=457
The readall method tries to store text file in one go.

Glaswegian
04-13-2011, 01:03 AM
Thanks for your reply - I'll have a look at that.

It may also be possible to reduce the size of the text file - I'm still investigating that though.