Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default 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
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
Copy worksheets from several workbooks into one workbook DSK 604 via OfficeKB.com Links and Linking in Excel 1 May 30th 10 03:47 PM
copy 10 workbooks to a combined workbook Phil Excel Worksheet Functions 1 May 24th 09 05:26 PM
want to copy many workbooks into 1 workbook april Excel Discussion (Misc queries) 1 August 13th 08 08:01 PM
HOW DO I COPY AND RENAME A WORKBOOK LINKED TO OTHER WORKBOOKS rlh3 Excel Discussion (Misc queries) 1 January 2nd 08 04:49 PM
copy sheet1 from all open workbooks to one workbook Mike[_61_] Excel Programming 2 October 31st 03 02:16 PM


All times are GMT +1. The time now is 06:19 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"