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 data

I've come up with the code but I don't know why there is
any error message highlighted at


Do While Not EOF(1)
Line Input #1, data
Worksheets("Sheet1").Activate
Line: Cells(i, 1).Value = Mid(data, 1, 8)
i=i +1
Loop


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Read text data

Per you later post, I believe you haven't initialized the value of i prior
to entering the loop. Thus in the cells(i,1) line it would resolve to
cells(0,1) which will give you an error.

--
Regards,
Tom Ogilvy

"hallie" wrote in message
...
I've come up with the code but I don't know why there is
any error message highlighted at


Do While Not EOF(1)
Line Input #1, data
Worksheets("Sheet1").Activate
Line: Cells(i, 1).Value = Mid(data, 1, 8)
i=i +1
Loop




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Read text data

If i = 0 initially that will error. If so, put i = i + 1 before the Cells
line.

Is there any reason to Activate Sheet1 in the loop? If not, put the
activate before the loop. In fact, if you use:

Worksheets("Sheet1").Cells(i, 1).Value = Mid(data, 1, 8)

you do not an activate at all.

--
Jim Rech
Excel MVP
"hallie" wrote in message
...
| I've come up with the code but I don't know why there is
| any error message highlighted at
|
|
| Do While Not EOF(1)
| Line Input #1, data
| Worksheets("Sheet1").Activate
| Line: Cells(i, 1).Value = Mid(data, 1, 8)
| i=i +1
| Loop
|
|


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Read text data

Hi Tom & Jim ,

In fact I've initialized to i to 1 before the start of
loop

I've replaced my code with the line below...

Worksheets("Whinv").Cells(i, 1).Value = Mid(data, 1, )

When I run , error stops at above line with same error
code of 1004 Application defined or object defined
error...

But my excel column is populated with values with blanks
rows in between certain rows eg..

A column
Row1 data1
Row2
Row3
Row3 data2
Row4
Row5 data3 etc etc



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Read text data

Thanks to everyone for your suggrstion..

I've found out the cause .. It's my silly mistake.
my counter increment was wrong. I treat "i" as 1.I'm not
going to use i as a variable again...

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
Data from exported file read as text, when edited becomes a # (pic Jarod Excel Discussion (Misc queries) 1 July 1st 09 02:21 AM
Can a cell be linked to read data entered into a text box ? theltgguy Excel Discussion (Misc queries) 0 May 11th 06 09:24 PM
Can a cell be linked to read data entered into a text box ? theltgguy Excel Discussion (Misc queries) 0 May 11th 06 09:15 PM
Read data from a text file (*.txt) Adrian T Excel Programming 0 June 4th 04 10:00 PM
Read/Write data to/from text files from a spreadsheet. lothario[_37_] Excel Programming 8 November 2nd 03 03:10 PM


All times are GMT +1. The time now is 08:55 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"