Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
minhao
 
Posts: n/a
Default Macro for moving sheets

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?

  #2   Report Post  
Dave O
 
Posts: n/a
Default

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.

  #3   Report Post  
minhao
 
Posts: n/a
Default

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 Befo=Workbooks("root.xls").Sheets(1)
End Sub


"Dave O" wrote:

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.


  #4   Report Post  
minhao
 
Posts: n/a
Default

Sorry , this should be the correct macro.

Sub Movesheet()
'
' Movesheet Macro
'
'

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

"minhao" wrote:

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 Befo=Workbooks("root.xls").Sheets(1)
End Sub


"Dave O" wrote:

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.


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
Macro help Jeff Garrett Excel Discussion (Misc queries) 11 December 1st 04 08:47 PM
macro - adding rows to a column that is summed HGood Excel Discussion (Misc queries) 2 December 1st 04 03:28 PM
Date and Time Macro m.j.anderson Excel Discussion (Misc queries) 1 December 1st 04 12:35 AM
macro interruption: help!!! mario milani Excel Discussion (Misc queries) 1 November 30th 04 06:02 PM
Macro for Show/Hide Column Andy Excel Discussion (Misc queries) 2 November 26th 04 01:03 PM


All times are GMT +1. The time now is 08:16 PM.

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

About Us

"It's about Microsoft Excel"