Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
to read text tablimited file | Excel Discussion (Misc queries) | |||
How do you save an excel file to be read as IBM-type text file ? | Excel Worksheet Functions | |||
read text file | Excel Programming | |||
Read data from a text file (*.txt) | Excel Programming | |||
Read text file | Excel Programming |