S
Steven Douglas
Hi,
I have some code where I open a very large file into
memory then enter a loop where I input each line one by
one, analyse it & draw data from it depending on certain
criteria.
The file being opened is 216,000 lines long and when the
code is running it just seems to get slower and slower
the further down the file it gets.
My question is, can I speed it up? I'm no expert, but
what I presume is happening is that Excel is, line by
line, opening more and more of the file into memory and
keeping it there. If that's the case, is there a way of
releasing the memory (of the lines) i no longer need?
I don't totally understand what the Filehandle & Freefile
things are, I just know that they work. In fact, would it
be quicker to use (Open openfile For Binary Access Read
As #Filehandle) & return data from the file that way?
(it's all the same place).
Any help on this would be greatly appreciated!
Thanks for your time,
Steven Douglas
Below is a very cut down version of the loop I'm running,
there are lot of other IF's & Do__Loop statements in
there, and I have them running as efficiently as possible.
'------------------------------------------------------
openfile = strDir & strBureau & "\XND.CSV"
Filehandle = FreeFile()
Open openfile For Input As #Filehandle
Do
Line Input #Filehandle, strData
If Mid(strData, 2, 1) = "A" Then
varkWh(1) = Mid(strData, 71, 8)
varkWh(2) = Mid(strData, 55, 13)
varkWh(3) = Mid(strData, 82, 30)
End If
'CAN i PUT A LINE HERE TO RELEASE MEMORY
Loop Until EOF(1)
'------------------------------------------------------
I have some code where I open a very large file into
memory then enter a loop where I input each line one by
one, analyse it & draw data from it depending on certain
criteria.
The file being opened is 216,000 lines long and when the
code is running it just seems to get slower and slower
the further down the file it gets.
My question is, can I speed it up? I'm no expert, but
what I presume is happening is that Excel is, line by
line, opening more and more of the file into memory and
keeping it there. If that's the case, is there a way of
releasing the memory (of the lines) i no longer need?
I don't totally understand what the Filehandle & Freefile
things are, I just know that they work. In fact, would it
be quicker to use (Open openfile For Binary Access Read
As #Filehandle) & return data from the file that way?
(it's all the same place).
Any help on this would be greatly appreciated!
Thanks for your time,
Steven Douglas
Below is a very cut down version of the loop I'm running,
there are lot of other IF's & Do__Loop statements in
there, and I have them running as efficiently as possible.
'------------------------------------------------------
openfile = strDir & strBureau & "\XND.CSV"
Filehandle = FreeFile()
Open openfile For Input As #Filehandle
Do
Line Input #Filehandle, strData
If Mid(strData, 2, 1) = "A" Then
varkWh(1) = Mid(strData, 71, 8)
varkWh(2) = Mid(strData, 55, 13)
varkWh(3) = Mid(strData, 82, 30)
End If
'CAN i PUT A LINE HERE TO RELEASE MEMORY
Loop Until EOF(1)
'------------------------------------------------------