LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default slow reading a file

Hello; I apologize if this is a duplicate post, but I posted over an hour ago
and it has not shown up yet.

I have a macro that imports a large text file into every fourth column.
Last week it ran fairly fast; this week it crawls. I estimate today that it
would take nearly 7 hours to import this file; last week to took 10 - 15
seconds. I haven't made any code changes, so I do not know what is wrong.
The size of the file keeps, growing - maybe that is the problem. I have even
tried using a better pc - still the same issue. Here is my code; I would
appreciate if someone who knows what they are doing would see if there is
something that could be changed to speed things up.

Sub Auto_Open()
MsgBox "Hello"
Columns("a:ir").EntireColumn.Clear
Dim FileName As String
Dim ResultStr As String
Dim FileNum As Integer
Dim Counter As Double
FileName = Application.GetOpenFilename
Application.ScreenUpdating = False
If FileName = "False" Then End
FileNum = FreeFile()
Open FileName For Input As #FileNum
Sheet1.Cells(2, 1).Select
Counter = 1
ColCounter = 4

Do While Seek(FileNum) <= LOF(FileNum)
If EOF(FileNum) Then End
Application.StatusBar = "Reading Row " & Counter & " of text file " &
FileName
Line Input #FileNum, ResultStr

ActiveCell.Value = ResultStr
If ActiveCell.Row = 65536 Then
ColCounter = ColCounter + 1
Sheet1.Cells(2, ColCounter).Select
Else
ActiveCell.Offset(1, 0).Select
End If
Counter = Counter + 1

Loop
Close
Application.ScreenUpdating = True
Application.StatusBar = False
End Sub

When I end the macro, the debugger stops at this line:

If ActiveCell.Row = 65536 Then

Any help and ideas would be greatly appreciated.

Thank you.


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
slow reading a text file into excel larrydave Excel Programming 5 December 11th 08 03:49 PM
Very Slow reading excel data into an array (while opened in new xl MikeZz Excel Programming 17 September 15th 08 06:38 PM
reading txt file and copying the lines in new excel file [email protected] Excel Programming 2 August 11th 06 07:20 PM
reading from another file and pasting to current file, "combobox" Darius New Users to Excel 1 September 26th 05 07:13 AM
reading from text file to excel file dgoel Excel Programming 0 April 18th 05 06:49 PM


All times are GMT +1. The time now is 09:44 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"