Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
The Sheet-Rename feature is greyed-out in my Excel 2003 workbook.. | Excel Discussion (Misc queries) | |||
How to open a new workbook and rename the workbook? | Excel Discussion (Misc queries) | |||
Move data to new sheet - rename sheet based on criteria ? | Excel Discussion (Misc queries) | |||
Insert sheet, move to end, rename with cell data. | Excel Discussion (Misc queries) | |||
Find and Open Workbook then copy and move sheet | Excel Programming |