Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Copy all workbooks into one workbook
Hi,
I have a folder with x number of workbooks, each workbook has one sheet and each sheet has a unique name. What I want to do is to copy all the sheets from all workbooks into a new workbook.. So if I have 10 workbooks I want to run a macro and get a new workbook with 10 sheets (the index order of the sheets in the new workbook is of no importance). I went to Ron De Bruins site which is very good btw but all I could find was code to copy workbooks in a folder and merge them in one sheet in a new workbook. I want to keep all sheets but put them in a single workbook Thanks, Jan Svendesen |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Copy all workbooks into one workbook
Jan,
try something like this: Sub test() Dim strPath As String Dim strFile As String Dim wbNew As Workbook Dim wbOld As Workbook strPath = "D:\Temp\" strFile = Dir(strPath & "*.xls") While strFile < "" Set wbOld = Workbooks.Open(strPath & strFile) If wbNew Is Nothing Then wbOld.Sheets(1).Copy Set wbNew = ActiveWorkbook Else wbOld.Sheets(1).Copy After:=wbNew.Sheets(wbNew.Sheets.Count) End If wbOld.Close False strFile = Dir Wend End Sub -- Hope that helps. Vergel Adriano "Jan Svendesen" wrote: Hi, I have a folder with x number of workbooks, each workbook has one sheet and each sheet has a unique name. What I want to do is to copy all the sheets from all workbooks into a new workbook.. So if I have 10 workbooks I want to run a macro and get a new workbook with 10 sheets (the index order of the sheets in the new workbook is of no importance). I went to Ron De Bruins site which is very good btw but all I could find was code to copy workbooks in a folder and merge them in one sheet in a new workbook. I want to keep all sheets but put them in a single workbook Thanks, Jan Svendesen |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Copy all workbooks into one workbook
Hi Jan,
I think that Ron also includes sample code to copy a sheet from each workbook into a master workbook. See, for example: Copy sheet from each workbook http://www.rondebruin.nl/fso.htm --- Regards, Norman Microsoft Excel MVP "Jan Svendesen" wrote in message ... Hi, I have a folder with x number of workbooks, each workbook has one sheet and each sheet has a unique name. What I want to do is to copy all the sheets from all workbooks into a new workbook.. So if I have 10 workbooks I want to run a macro and get a new workbook with 10 sheets (the index order of the sheets in the new workbook is of no importance). I went to Ron De Bruins site which is very good btw but all I could find was code to copy workbooks in a folder and merge them in one sheet in a new workbook. I want to keep all sheets but put them in a single workbook Thanks, Jan Svendesen |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Copy all workbooks into one workbook
Thanks
Jan "Vergel Adriano" wrote in message ... Jan, try something like this: Sub test() Dim strPath As String Dim strFile As String Dim wbNew As Workbook Dim wbOld As Workbook strPath = "D:\Temp\" strFile = Dir(strPath & "*.xls") While strFile < "" Set wbOld = Workbooks.Open(strPath & strFile) If wbNew Is Nothing Then wbOld.Sheets(1).Copy Set wbNew = ActiveWorkbook Else wbOld.Sheets(1).Copy After:=wbNew.Sheets(wbNew.Sheets.Count) End If wbOld.Close False strFile = Dir Wend End Sub -- Hope that helps. Vergel Adriano "Jan Svendesen" wrote: Hi, I have a folder with x number of workbooks, each workbook has one sheet and each sheet has a unique name. What I want to do is to copy all the sheets from all workbooks into a new workbook.. So if I have 10 workbooks I want to run a macro and get a new workbook with 10 sheets (the index order of the sheets in the new workbook is of no importance). I went to Ron De Bruins site which is very good btw but all I could find was code to copy workbooks in a folder and merge them in one sheet in a new workbook. I want to keep all sheets but put them in a single workbook Thanks, Jan Svendesen |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Copy all workbooks into one workbook
You are correct,
thanks Jan "Norman Jones" wrote in message ... Hi Jan, I think that Ron also includes sample code to copy a sheet from each workbook into a master workbook. See, for example: Copy sheet from each workbook http://www.rondebruin.nl/fso.htm --- Regards, Norman Microsoft Excel MVP "Jan Svendesen" wrote in message ... Hi, I have a folder with x number of workbooks, each workbook has one sheet and each sheet has a unique name. What I want to do is to copy all the sheets from all workbooks into a new workbook.. So if I have 10 workbooks I want to run a macro and get a new workbook with 10 sheets (the index order of the sheets in the new workbook is of no importance). I went to Ron De Bruins site which is very good btw but all I could find was code to copy workbooks in a folder and merge them in one sheet in a new workbook. I want to keep all sheets but put them in a single workbook Thanks, Jan Svendesen |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Copy all workbooks into one workbook
And I also add a filter example yesterday to the page
-- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "Norman Jones" wrote in message ... Hi Jan, I think that Ron also includes sample code to copy a sheet from each workbook into a master workbook. See, for example: Copy sheet from each workbook http://www.rondebruin.nl/fso.htm --- Regards, Norman Microsoft Excel MVP "Jan Svendesen" wrote in message ... Hi, I have a folder with x number of workbooks, each workbook has one sheet and each sheet has a unique name. What I want to do is to copy all the sheets from all workbooks into a new workbook.. So if I have 10 workbooks I want to run a macro and get a new workbook with 10 sheets (the index order of the sheets in the new workbook is of no importance). I went to Ron De Bruins site which is very good btw but all I could find was code to copy workbooks in a folder and merge them in one sheet in a new workbook. I want to keep all sheets but put them in a single workbook Thanks, Jan Svendesen |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Copy worksheets from several workbooks into one workbook | Links and Linking in Excel | |||
copy 10 workbooks to a combined workbook | Excel Worksheet Functions | |||
want to copy many workbooks into 1 workbook | Excel Discussion (Misc queries) | |||
HOW DO I COPY AND RENAME A WORKBOOK LINKED TO OTHER WORKBOOKS | Excel Discussion (Misc queries) | |||
copy sheet1 from all open workbooks to one workbook | Excel Programming |