ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Read previous line of textfile (https://www.excelbanter.com/excel-programming/296878-read-previous-line-textfile.html)

Adrian[_4_]

Read previous line of textfile
 
I have a text file that I want to read line by line, but
BACKWARDS !!

The ReadLine method reads the next line.
But I need to read the last line first, then the previous
line, working backwards to the beginning etc etc.
(Each line needs to be the right way round within itself.)
The text files are typically 50,000 lines long.

Any ideas?

Tom Ogilvy

Read previous line of textfile
 
Probably easiest to open it in Excel, then work from the last row to the
first.

--
Regards,
Tom Ogilvy

"Adrian" wrote in message
...
I have a text file that I want to read line by line, but
BACKWARDS !!

The ReadLine method reads the next line.
But I need to read the last line first, then the previous
line, working backwards to the beginning etc etc.
(Each line needs to be the right way round within itself.)
The text files are typically 50,000 lines long.

Any ideas?




Tim Williams

Read previous line of textfile
 
Read the whole file into a variable and use split(strVar,vbvrlf) to
assign it to an array.

Then work from the upper to lower bound of the array.

Tim.


"Adrian" wrote in message
...
I have a text file that I want to read line by line, but
BACKWARDS !!

The ReadLine method reads the next line.
But I need to read the last line first, then the previous
line, working backwards to the beginning etc etc.
(Each line needs to be the right way round within itself.)
The text files are typically 50,000 lines long.

Any ideas?





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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com