Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Move Files from Folder to Folder

***Sorry I'm reposting because I placed it in the wrong category****

I have a macro that goes into a folder, grabs all excel documents and
combines into one workbook. I want to move that particular file after its
combined to the master file. Basically, I have two folders

1. New
2 Old

I use the code below. Once I use the file I would like to move it to the Old
Folder. So, the next day it will be ready for the next group of files. Thanks

Application.EnableEvents = False
Application.ScreenUpdating = False
Path = "c:\new" ''Change as needed
FileName = Dir(Path & "\*.xls", vbNormal)
Do Until FileName = ""
Set Wkb2 = Workbooks.Open(FileName:=Path & "\" & FileName)
For Each WS In Wkb2.Worksheets
WS.Copy After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Cou nt)
Next WS
Wkb2.Close False
FileName = Dir()
Loop
Application.EnableEvents = True
Application.ScreenUpdating = True
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Move Files from Folder to Folder

You can use the Name statement to name your C:\New folder to
C:\Old, then use Midair to recreate the C:\New folder. Eg.,

Name "C:\New" As "C:\Old"
MkDir "C:\New"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"THE_RAMONES" wrote in
message
...
***Sorry I'm reposting because I placed it in the wrong
category****

I have a macro that goes into a folder, grabs all excel
documents and
combines into one workbook. I want to move that particular file
after its
combined to the master file. Basically, I have two folders

1. New
2 Old

I use the code below. Once I use the file I would like to move
it to the Old
Folder. So, the next day it will be ready for the next group of
files. Thanks

Application.EnableEvents = False
Application.ScreenUpdating = False
Path = "c:\new" ''Change as needed
FileName = Dir(Path & "\*.xls", vbNormal)
Do Until FileName = ""
Set Wkb2 = Workbooks.Open(FileName:=Path & "\" & FileName)
For Each WS In Wkb2.Worksheets
WS.Copy After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Cou nt)
Next WS
Wkb2.Close False
FileName = Dir()
Loop
Application.EnableEvents = True
Application.ScreenUpdating = True



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Move Files from Folder to Folder

My old folder should be a cumulative total of all old files. So, if I
understand this correctly I will be renaming the new folder to old however I
would overwrite all the old files. If I'm totally messing this thought up
please let me know. Thanks

Ramon


"Chip Pearson" wrote:

You can use the Name statement to name your C:\New folder to
C:\Old, then use Midair to recreate the C:\New folder. Eg.,

Name "C:\New" As "C:\Old"
MkDir "C:\New"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"THE_RAMONES" wrote in
message
...
***Sorry I'm reposting because I placed it in the wrong
category****

I have a macro that goes into a folder, grabs all excel
documents and
combines into one workbook. I want to move that particular file
after its
combined to the master file. Basically, I have two folders

1. New
2 Old

I use the code below. Once I use the file I would like to move
it to the Old
Folder. So, the next day it will be ready for the next group of
files. Thanks

Application.EnableEvents = False
Application.ScreenUpdating = False
Path = "c:\new" ''Change as needed
FileName = Dir(Path & "\*.xls", vbNormal)
Do Until FileName = ""
Set Wkb2 = Workbooks.Open(FileName:=Path & "\" & FileName)
For Each WS In Wkb2.Worksheets
WS.Copy After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Cou nt)
Next WS
Wkb2.Close False
FileName = Dir()
Loop
Application.EnableEvents = True
Application.ScreenUpdating = True




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
Pulling pdf files from general folder to specific folder [email protected] Excel Discussion (Misc queries) 2 September 8th 09 09:41 PM
Copying all files in a folder to new folder michaelberrier Excel Discussion (Misc queries) 2 June 20th 06 05:35 AM
how can I specific a folder with wildcard criteria and excel will import all the correct files in that folder? Raven Excel Discussion (Misc queries) 1 January 24th 06 03:28 PM
how can I specific a folder with wildcard criteria and excel will import all the correct files in that folder? Raven[_2_] Excel Programming 1 January 24th 06 04:23 AM
How to copy 30 csv files from a folder to another folder ddiicc Excel Programming 1 July 17th 05 09:42 AM


All times are GMT +1. The time now is 06:27 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"