ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   read text file (https://www.excelbanter.com/excel-programming/307174-read-text-file.html)

hallie

read text file
 
my text file is of fixed width format..I have 2 problems
that I've tried to troubleshoot..

1) An error is highlighted at Line 5 (RunTime error 1004
Application-defined or object-defined error)

2)The data was correctly diplayed in cells BUT there are
blanks rows between the cells with correct data( the nos
of blank row varies)


par of the code:
Do While Not EOF(1)
Line Input #1, data
Worksheets("Sheet1").Activate

Line5: Cells(i, 1).Value = Mid(data, 1, 8)
i=i+1
Loop


some kind member pls advise ...thanks


Tom Ogilvy

read text file
 
I can't say why you get blank lines - are you sure you txt file doesn't have
blank lines in it.

As far as the error, I suspect you haven't initialized the value of i to a
legitimate row number before you loop starts.

--
Regards,
Tom Ogilvy

"hallie" wrote in message
...
my text file is of fixed width format..I have 2 problems
that I've tried to troubleshoot..

1) An error is highlighted at Line 5 (RunTime error 1004
Application-defined or object-defined error)

2)The data was correctly diplayed in cells BUT there are
blanks rows between the cells with correct data( the nos
of blank row varies)


par of the code:
Do While Not EOF(1)
Line Input #1, data
Worksheets("Sheet1").Activate

Line5: Cells(i, 1).Value = Mid(data, 1, 8)
i=i+1
Loop


some kind member pls advise ...thanks





All times are GMT +1. The time now is 04:21 PM.

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