View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Srikanth Srikanth is offline
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