Hi Guys,
So I need to import a large text file into an array. I only need the last 5,000 lines or so. Most of the files are ok, but occasionally (around 30000 lines) I get an overflow error. Since I only need the last five thousand lines or so, is there a way to delete the beginning part of the array as more is added after 5,000 lines, I.E. when line 5001 is imported line 1 gets erased? I tried the below but still got the overflow error. I wouldn't have to delete pieces of the array one at a time, either - I could say that at 10,000 the first 5000 get deleted, at 15,000 the next 5000 get deleted, etc. Or might I just be better off reading the file twice to count the lines?
Code:
Do While Not fo.AtEndOfStream
Count = Count + 1
ReDim Preserve AllArray(Count)
AllArray(Count) = fo.ReadLine
'If Count > 5000 Then AllArray(Count - 5000) = ""
Loop
Thanks!