#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 209
Default Copy sheets

Hi
Is there a way to copy all sheets from one workbook to antother workbook
if i don't know how many sheets there are?


Best regards alvin

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Copy sheets

Hi Alvin

If Workbooks("Book2") is open it will copy the worksheets of the activeworkbook to Book2

ActiveWorkbook.Worksheets.Copy after:=Workbooks("Book2").Sheets(Workbooks("Book2" ).Sheets.Count)

You can also use Sheets.Copy if you have chart sheets also

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Alvin Hansen" wrote in message ...
Hi
Is there a way to copy all sheets from one workbook to antother workbook
if i don't know how many sheets there are?


Best regards alvin



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 209
Default Copy sheets

Hi Ron
Well the Workbook i want to get the sheets from is close

Alvin



"Ron de Bruin" skrev:

Hi Alvin

If Workbooks("Book2") is open it will copy the worksheets of the activeworkbook to Book2

ActiveWorkbook.Worksheets.Copy after:=Workbooks("Book2").Sheets(Workbooks("Book2" ).Sheets.Count)

You can also use Sheets.Copy if you have chart sheets also

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Alvin Hansen" wrote in message ...
Hi
Is there a way to copy all sheets from one workbook to antother workbook
if i don't know how many sheets there are?


Best regards alvin




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Copy sheets

Hi Alvin

Try this then

Sub test()
Dim Wb1 As Workbook
Dim Wb2 As Workbook
Application.ScreenUpdating = False
Set Wb1 = ActiveWorkbook
Set Wb2 = Workbooks.Open("C:\data\ron.xls")
Wb2.Worksheets.copy _
after:=Wb1.Sheets(WB1.Sheets.Count)
Wb2.Close False
Application.ScreenUpdating = True
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Alvin Hansen" wrote in message ...
Hi Ron
Well the Workbook i want to get the sheets from is close

Alvin



"Ron de Bruin" skrev:

Hi Alvin

If Workbooks("Book2") is open it will copy the worksheets of the activeworkbook to Book2

ActiveWorkbook.Worksheets.Copy after:=Workbooks("Book2").Sheets(Workbooks("Book2" ).Sheets.Count)

You can also use Sheets.Copy if you have chart sheets also

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Alvin Hansen" wrote in message
...
Hi
Is there a way to copy all sheets from one workbook to antother workbook
if i don't know how many sheets there are?


Best regards alvin






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 209
Default Copy sheets

It's Working Ron

Thanks again
Alvin


"Ron de Bruin" skrev:

Hi Alvin

Try this then

Sub test()
Dim Wb1 As Workbook
Dim Wb2 As Workbook
Application.ScreenUpdating = False
Set Wb1 = ActiveWorkbook
Set Wb2 = Workbooks.Open("C:\data\ron.xls")
Wb2.Worksheets.copy _
after:=Wb1.Sheets(WB1.Sheets.Count)
Wb2.Close False
Application.ScreenUpdating = True
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Alvin Hansen" wrote in message ...
Hi Ron
Well the Workbook i want to get the sheets from is close

Alvin



"Ron de Bruin" skrev:

Hi Alvin

If Workbooks("Book2") is open it will copy the worksheets of the activeworkbook to Book2

ActiveWorkbook.Worksheets.Copy after:=Workbooks("Book2").Sheets(Workbooks("Book2" ).Sheets.Count)

You can also use Sheets.Copy if you have chart sheets also

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Alvin Hansen" wrote in message
...
Hi
Is there a way to copy all sheets from one workbook to antother workbook
if i don't know how many sheets there are?


Best regards alvin









  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Copy sheets

You are welcome

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Alvin Hansen" wrote in message ...
It's Working Ron

Thanks again
Alvin


"Ron de Bruin" skrev:

Hi Alvin

Try this then

Sub test()
Dim Wb1 As Workbook
Dim Wb2 As Workbook
Application.ScreenUpdating = False
Set Wb1 = ActiveWorkbook
Set Wb2 = Workbooks.Open("C:\data\ron.xls")
Wb2.Worksheets.copy _
after:=Wb1.Sheets(WB1.Sheets.Count)
Wb2.Close False
Application.ScreenUpdating = True
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Alvin Hansen" wrote in message
...
Hi Ron
Well the Workbook i want to get the sheets from is close

Alvin



"Ron de Bruin" skrev:

Hi Alvin

If Workbooks("Book2") is open it will copy the worksheets of the activeworkbook to Book2

ActiveWorkbook.Worksheets.Copy after:=Workbooks("Book2").Sheets(Workbooks("Book2" ).Sheets.Count)

You can also use Sheets.Copy if you have chart sheets also

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Alvin Hansen" wrote in message
...
Hi
Is there a way to copy all sheets from one workbook to antother workbook
if i don't know how many sheets there are?


Best regards alvin









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 cell info to other sheets, other sheets dont contain all row. Ja Excel Worksheet Functions 1 November 1st 09 12:53 AM
copy sheets kathy Excel Discussion (Misc queries) 3 September 15th 09 03:21 PM
move or copy sheets doesn't copy format ColinX Excel Worksheet Functions 1 May 14th 08 10:07 PM
in VBA Sheets("mysheet").Copy Befo=Sheets(1) how do i get a reference to the newly created copy of this sheet? Daniel Excel Worksheet Functions 1 July 6th 05 09:57 PM
Copy Sheets Edgar Excel Programming 0 April 28th 04 10:49 AM


All times are GMT +1. The time now is 06:02 AM.

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"