Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default copy several sheets from a workbook to a single sheet in a new wor

Hi,

Private Sub CommandButton1_Click()
Dim Wbmain As Workbook
Workbooks.Open ("C:\Source.xls")
Workbooks("Source.xls").Activate
Set Wbmain = ActiveWorkbook
Call CopySheets(Wbmain)
End Sub

Sub CopySheets(Wbmain As Workbook)

Dim wS As Worksheet
Dim wbNew As Workbook
Set wbNew = Workbooks.Add
For Each wS In Wbmain.Worksheets
wS.Copy after:=wbNew.Sheets(wbNew.Sheets.Count)
Next wS
End Sub

Above code creates a new workbook and copy the sheets of the source.xls file
in the new workbook..
I need to paste all the contents of source.xls as single sheet in new
workbook..
(i.e., if source.xls contains 3 sheets, then all the contents of 3 sheets
must be pasted in a single sheet in new workbook)..
Can you please help me with some code..

thank you ,
srikanth
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default copy several sheets from a workbook to a single sheet in a new wor

Ron has several examples, this one is pretty close to what you want:
http://www.rondebruin.nl/copy3tip.htm

Mike F
"srikanth" wrote in message
...
Hi,

Private Sub CommandButton1_Click()
Dim Wbmain As Workbook
Workbooks.Open ("C:\Source.xls")
Workbooks("Source.xls").Activate
Set Wbmain = ActiveWorkbook
Call CopySheets(Wbmain)
End Sub

Sub CopySheets(Wbmain As Workbook)

Dim wS As Worksheet
Dim wbNew As Workbook
Set wbNew = Workbooks.Add
For Each wS In Wbmain.Worksheets
wS.Copy after:=wbNew.Sheets(wbNew.Sheets.Count)
Next wS
End Sub

Above code creates a new workbook and copy the sheets of the source.xls
file
in the new workbook..
I need to paste all the contents of source.xls as single sheet in new
workbook..
(i.e., if source.xls contains 3 sheets, then all the contents of 3 sheets
must be pasted in a single sheet in new workbook)..
Can you please help me with some code..

thank you ,
srikanth



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default copy several sheets from a workbook to a single sheet in a new

Thanks a lot Mike.. I got the code and made some arrangements and it works
fine..
thank you a lot...


"Mike Fogleman" wrote:

Ron has several examples, this one is pretty close to what you want:
http://www.rondebruin.nl/copy3tip.htm

Mike F
"srikanth" wrote in message
...
Hi,

Private Sub CommandButton1_Click()
Dim Wbmain As Workbook
Workbooks.Open ("C:\Source.xls")
Workbooks("Source.xls").Activate
Set Wbmain = ActiveWorkbook
Call CopySheets(Wbmain)
End Sub

Sub CopySheets(Wbmain As Workbook)

Dim wS As Worksheet
Dim wbNew As Workbook
Set wbNew = Workbooks.Add
For Each wS In Wbmain.Worksheets
wS.Copy after:=wbNew.Sheets(wbNew.Sheets.Count)
Next wS
End Sub

Above code creates a new workbook and copy the sheets of the source.xls
file
in the new workbook..
I need to paste all the contents of source.xls as single sheet in new
workbook..
(i.e., if source.xls contains 3 sheets, then all the contents of 3 sheets
must be pasted in a single sheet in new workbook)..
Can you please help me with some code..

thank you ,
srikanth




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
selecting a single sheet from a volume of sheets in a workbook No News Excel Worksheet Functions 12 July 1st 06 05:29 AM
Copy and paste data from one sheet to another in a single workbook SITCFanTN Excel Programming 0 June 10th 06 01:58 PM
copy data in one sheet to multiple sheets in same workbook BrianMultiLanguage Excel Worksheet Functions 4 July 27th 05 07:26 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
is it possible to use F9 to manually calculate in a single sheet or single workbook? Hersbt Excel Discussion (Misc queries) 2 December 29th 04 04:42 PM


All times are GMT +1. The time now is 11:01 AM.

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"