LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Open a sheet rename and move to another workbook

Ok,
I have gotten the code below to work BUT it loops on the same file instead
of moving on to the next file. My goal is to open all the files in a
particular directory, renmae the worksheet with the file name and then move
that worksheet to the workbook which the macro is running from i.e. in this
case book2.
Any fix for the incorrect looping?
Only learning here and so need a lot of help
Patrick


Sub AllFolderFiles()
Dim wb As Workbook
Dim TheFile As String
Dim MyPath As String
MyPath = "F:\Work Stuff 2\Work Stuff\Promotion Report"
ChDir MyPath
TheFile = Dir("*.xls")
Do While TheFile < ""
Set wb = Workbooks.Open(MyPath & "\" & TheFile)
ActiveSheet.Name = ActiveWorkbook.Name
ActiveSheet.Move After:=Workbooks("Book2").Sheets(Sheets.Count)
Loop
End Sub


 
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
The Sheet-Rename feature is greyed-out in my Excel 2003 workbook.. Marlene Excel Discussion (Misc queries) 1 January 29th 10 09:43 PM
How to open a new workbook and rename the workbook? pokdbz Excel Discussion (Misc queries) 3 December 26th 07 03:37 PM
Move data to new sheet - rename sheet based on criteria ? [email protected] Excel Discussion (Misc queries) 7 May 16th 07 10:22 PM
Insert sheet, move to end, rename with cell data. [email protected] Excel Discussion (Misc queries) 2 October 11th 05 03:04 PM
Find and Open Workbook then copy and move sheet cwilson Excel Programming 0 February 2nd 05 07:29 PM


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