Sub GetBooks()
Folder = "C:\Temp\"
'Get each XLS file in the Folder, will return an empty string after last file
FName = Dir(Folder & "*.xls")
'loop until there are no more files to open
Do While FName <> ""
'Open sleected file
Set OldBk = Workbooks.Open(Filename:=Folder & FName)
'open workbook become active so must specify original book
With ThisWorkbook
'copy sheet from open book to this book
'Require AFTER otherwise sheet goes in a new workbook
'Place Copied sheet as last sheet in workbook
OldBk.ActiveSheet.Copy _
after:=.Sheets(.Sheets.Count)
'Make sheet name the same as workbook name
ActiveSheet.Name = FName
End With
'close workbook that was opened.
'specify savechanges false so nothing is changed in opened book
'also savechanges are needed so pop-up window doesn't
'show up after every file.
OldBk.Close savechanges:=False
'get next file in search criteria
FName = Dir()
Loop
End Sub
"Heera" wrote:
> Hi,
>
> Joel your code is working fine. I would appriciate if you can explain
> me what this macro is doing at each step. It will be a great help for
> me next time when ever i write the macro.
>
> Regards
>
> Heera
>
|