Macro for moving sheets

M

minhao

Hi
I have tons of data files in ASCII format.
I want to move all individual files as sheets in one excel file.
Is there anyway to program a macro to do this?
 
D

Dave O

It can be done, and the best way to get started is to record the macro
to perform the operation once, then alter the macro to accommodate the
rest of the files. Additionally, you may need to have 2 files open at
once: the "master" file that holds the imported text files, and a
"temporary" file that imports the text file. The macro may need to
switch from one file to the other to move the imported tab from the
temporary file to the master, and then close the temporary file.
You can post your code to this newsgroup for debugging assistance.
 
M

minhao

Hi Dave
Thanks for your reply
I have recorded the macro to move a sheet from the txt file to a root file.

How do I program it to move all the txt files to the root file?
I have named the file in such a way that the last two digits are in a
running series.
For example 04120801, 04120802,....04120899

Minhao


Sub Movesheet()
'
' Movesheet Macro
'

'
Sheets("04120802").Select
Sheets("04120802").Move Before:=Workbooks("root.xls").Sheets(1)
End Sub
 
M

minhao

Sorry , this should be the correct macro.

Sub Movesheet()
'
' Movesheet Macro
'
'

'
Windows("04120803.txt").Activate
Sheets("04120803").Select
Sheets("04120803").Move Before:=Workbooks("root.xls").Sheets(1)
Windows("04120802.txt").Activate
Sheets("04120802").Select
Sheets("04120802").Move Before:=Workbooks("root.xls").Sheets(1)
Windows("04120801.txt").Activate
Sheets("04120801").Select
Sheets("04120801").Move Before:=Workbooks("root.xls").Sheets(1)
End Sub
 
Top