Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 340
Default read text file

Hallie, what is the initial value if "i"? Is it zero? If so, that would
mean that your macro is trying to write to cells(0,1), which does not exist.
Is the error occuring after some lines have been read in? If so, then
Mid(data, 1,8) is returning something that Excel is tryng to calculate or
put into a cell that won't fit. if so, then when the error happs highlight
Mid(data, 1, 8) and do a watch on it to see what the characters are. If all
the data you are reading in is text, then you could do this:

Cells(i, 1).Value = "'" & Mid(data, 1, 8)

Robert Flanagan
Macro Systems
Delaware, U.S. 302-234-9857
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel


"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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default read text file

Hi Bob,
thanks for your reply...
I declare i as long and set it to 1 before the start of
the DO while loop..
Yes correct data is wriiten to the cells but there are
blanks rows between those rows with data in it...it's
strange

I tried Cells(i, 1).Value = "'" & Mid(data, 1, 8) ...
same results..



Reply
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
to read text tablimited file pol Excel Discussion (Misc queries) 2 May 27th 09 01:14 PM
How do you save an excel file to be read as IBM-type text file ? Dee Franklin Excel Worksheet Functions 2 October 10th 06 02:46 AM
read text file hallie Excel Programming 1 August 17th 04 12:37 PM
Read data from a text file (*.txt) Adrian T Excel Programming 0 June 4th 04 10:00 PM
Read text file jacob[_3_] Excel Programming 2 September 23rd 03 06:41 PM


All times are GMT +1. The time now is 05:43 PM.

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"