LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7
Default "read" inputs past end of file

The only problem that I see here is that my data doesnt fill sheet1 range
(a1:aXX). My data is in specific cells on multiple pages but I think this is
enough information to allow me to get what I need done. Ill update whether or
not this works soon.

Thanks!

"Joel" wrote:

then re-arrange your loop

Open strFile For Input As #2
for i = 1 to 500 '<=change to you r actual last row
if eof(2) then
Sheets("example").Range("a" & i) = ""
else
Input #2, a1
Sheets("example").Range("a" & i) = a1
end if
next i



"Japazo88" wrote:

Well, what happens is the program uses a userform to create a .txt savefile
and writes all the user inputs line by line.

Open strFile For Output As #2
Write #2, Sheets("example").Range("a1")
Write #2, Sheets("example").Range("a2")
Write #2, Sheets("example").Range("a3")
etc...

then, when I want to open one of the old savefiles it begins the same
process in reverse,

Open strFile For Input As #2
Input #2, a1
Sheets("example").Range("a1") = a1
Input #2, a1
Sheets("example").Range("a2") = a1
Input #2, a1
Sheets("example").Range("a3") = a1

etc...

The problem arises when the Macro hits the EOF of the savefile. It has a
line that says

Input #2, a1
Sheets("example").Range("a500") = a1

when a500 was never saved in the old program's output file. So what I want
to do in order to do away with one macro for opening old files and one macro
for opening new ones is to basically say,

if eof then
input #2 = ""

so that it can read until the end of the file then input blanks after that.
Does that make more sense?

"Joel" wrote:

Why don't you clear the cells before reading in the text file. The program
should only read in the data from the text files and the other cells will
remain blank.

"Japazo88" wrote:

Hello everyone,

Lets say I have two programs written in excel that are used to automatically
select the right car for a person based on height, weight, etc. Both programs
do the same thing but the newer version has more inputs and outputs (saved to
a .txt) than the old one. My problem is that when trying to read the data
from the old saved files I get an "Input Past End of File" error. Basically
what I want to do is have the program read all the available data from the
text file then fill in the rest of the program input cells as blank. The
addition of more inputs wasnt taken into account when the old program was
written otherwise empty cells would have been written to allow for the new
inputs.

What is my best option for filling in blanks once Ive reached the end of the
.txt file?

Thanks in advance!



 
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
"Unable to Read File" error message in Excel - solutions? Presby Loaner Excel Discussion (Misc queries) 2 June 27th 07 05:09 PM
"Cannot access read-only document" (I get this error when I try to open an Excel file) [email protected] Excel Discussion (Misc queries) 1 June 5th 06 01:15 PM
"Cannot access read-only document" (I get this error when I try to open an Excel file) [email protected] Setting up and Configuration of Excel 1 June 5th 06 01:15 PM
XCEL FILE REC'D AS READ ONLY -- HOW TO NOT BE "READ ONLY" billybob Excel Discussion (Misc queries) 1 February 13th 06 03:14 AM
Excel 2002/2003 can not open xls file says "may be read only" Number6 Excel Discussion (Misc queries) 3 December 20th 05 05:25 PM


All times are GMT +1. The time now is 12:53 PM.

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"