Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default to join more workbooks in one

Dear friends
I have the macro below that works fine but I don’t understand how the
new workbook that will contain all sheets is open (I can see a copy
command but I don’t see a paste command). How can I give a specific
name to the new workbook and save it in a specific forlder? I would
like also close the workbook I had previously open without saving it.
Thank you very much for your help

bkList = Array("Bk1.xls", "Bk2.xls", "Bk3.xls", _
"Bk4.xls", "Bk5.xls", "Bk6.xls", "Bk7.xls")
for i = lbound(bkList) to ubound(bklist)
set wkbk = workbooks.Open(blList(i))
if i = lbound(bkList) then
wkbk.Sheets.copy
set wkbk1 = ActiveWorkbook
else
wkbk.Sheets.Copy After:=wkbk1.Sheets(wkbk1.sheets.count)
end if
Next
' now delete sheets you don't want
wkbk1.Sheets.Select
activewindows.SelectedSheets.Printout


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default to join more workbooks in one

the copy command is copying sheets. When you copy sheets and don't specify
a destination, Excel places them in a new workbook which it creates (thus no
paste is required). This is now the activeworkbook.

wkbk1 then holds a reference to this workbook, so if you want to save it
just do

wkbk1.SaveAs Filename:="C:\MyFolders\newname.xls"

bkList = Array("Bk1.xls", "Bk2.xls", "Bk3.xls", _
"Bk4.xls", "Bk5.xls", "Bk6.xls", "Bk7.xls")
for i = lbound(bkList) to ubound(bklist)
set wkbk = workbooks.Open(blList(i))
if i = lbound(bkList) then
wkbk.Sheets.copy
set wkbk1 = ActiveWorkbook
else
wkbk.Sheets.Copy After:=wkbk1.Sheets(wkbk1.sheets.count)
end if
Next
' now delete sheets you don't want
wkbk1.Sheets.Select
activewindows.SelectedSheets.Printout

--
Regards,
Tom Ogilvy





71marco71 wrote in message
...
Dear friends
I have the macro below that works fine but I don't understand how the
new workbook that will contain all sheets is open (I can see a copy
command but I don't see a paste command). How can I give a specific
name to the new workbook and save it in a specific forlder? I would
like also close the workbook I had previously open without saving it.
Thank you very much for your help

bkList = Array("Bk1.xls", "Bk2.xls", "Bk3.xls", _
"Bk4.xls", "Bk5.xls", "Bk6.xls", "Bk7.xls")
for i = lbound(bkList) to ubound(bklist)
set wkbk = workbooks.Open(blList(i))
if i = lbound(bkList) then
wkbk.Sheets.copy
set wkbk1 = ActiveWorkbook
else
wkbk.Sheets.Copy After:=wkbk1.Sheets(wkbk1.sheets.count)
end if
Next
' now delete sheets you don't want
wkbk1.Sheets.Select
activewindows.SelectedSheets.Printout


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default to join more workbooks in one

Hi tom
Now I have understandood how the new workbook has been created but
don’t know where I have to write the macro. I would like to write th
macro in one sheet named “report” and copy to it every month all sheet
contained in the others workbooks I want to join. So, I think, It'
necessary every month to delete all sheets contained in "Report" an
than copy the new sheets. Before printing I would like also to numbe
the pages. I have tried to do this but in vain.
Thanks in advance for your precious hel

--
Message posted from http://www.ExcelForum.com

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
macro to join sheets from different workbooks arashi New Users to Excel 1 February 11th 11 10:00 AM
how do I join two separate workbooks? Mike[_22_] New Users to Excel 1 June 10th 09 07:58 PM
Join workbooks ruby Excel Discussion (Misc queries) 3 June 9th 09 06:33 PM
How do I join two workbooks into one pivot table? Eqa Excel Worksheet Functions 0 March 29th 07 07:54 AM
join more workbooks in one and print sheets 71marco71[_4_] Excel Programming 3 February 6th 04 06:14 PM


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