|
-
Sep 22nd, 2000, 08:37 AM
#1
Thread Starter
Addicted Member
I have been reading the threads on the use of OPEN, GET, PUT, INPUT, APPEND etc...
I haven't found any thread that could explain the following problem.
What would be the best way to take lets say 20 text files and put them into individual spreadsheets within a workbook. The way I would have done it is to just open the file with its specific delimeters and then move it into the master workbook, but is this the most efficient.
Is there a better way by reading the text file into memory/clipboard/array and then somehow pasting into a spreadsheet.
Thanks for any help
Steve
-
Sep 23rd, 2000, 10:18 PM
#2
Lively Member
This depends if you know how each of the text files are set out, say seperated by a tab, or if they are set on seperate lines...
If you know the layout of the data then you could use an OPEN command to place each respective bit of data into a variable for example
Code:
Sub OpenFile()
Dim MyVariable(1 to 2000) As String, MyInteger As Integer
MyInteger = 1
Open "C:\MyFile.txt" For Input As #1
'Do A Loop to grab all the data, I'm asuming that each line is a seperate set of data
While Not EOF(1)
Input #1, MyVariable(MyInteger)
MyInteger = MyInteger + 1
Wend
Close #1
Then Basically all you would need to do is open your workbook that needs this data and then reset the integer back to 1 and place on in each cell using another loop e.g.
Code:
MyInteger = 1
Range("A1").select
While MyVariable(MyInteger) <> ""
ActiveCell.Value = MyVariable
ActiveCell.Offset(0,1).select 'Or Offset(1,0) depending on whether you want to go accross or down
MyInteger = My Integer + 1
Wend
This is normally quicker than actually copying all the info from the text file and then placing it into the worksheet
-
Sep 25th, 2000, 04:22 AM
#3
Thread Starter
Addicted Member
Anybody got any ideas !!
Sorry about re-posting this, but it would really help me out if I could get to the bottom of this...
Steve
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|