PC Review


Reply
Thread Tools Rate Thread

copy several sheets from a workbook to a single sheet in a new wor

 
 
=?Utf-8?B?c3Jpa2FudGg=?=
Guest
Posts: n/a
 
      22nd Feb 2007
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 With Quote
 
 
 
 
Mike Fogleman
Guest
Posts: n/a
 
      22nd Feb 2007
Ron has several examples, this one is pretty close to what you want:
http://www.rondebruin.nl/copy3tip.htm

Mike F
"srikanth" <(E-Mail Removed)> wrote in message
news:FA0BBBF6-63F6-4253-BB84-(E-Mail Removed)...
> 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 With Quote
 
=?Utf-8?B?c3Jpa2FudGg=?=
Guest
Posts: n/a
 
      23rd Feb 2007
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" <(E-Mail Removed)> wrote in message
> news:FA0BBBF6-63F6-4253-BB84-(E-Mail Removed)...
> > 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Copy a sum of a column from different Excel sheets to a single master excel sheet? Sriram Microsoft Excel Programming 0 12th Dec 2007 09:38 PM
copy sheets to workbook and save as sheet name =?Utf-8?B?dW1waXJlXzQz?= Microsoft Excel Programming 2 4th Oct 2007 08:07 PM
selecting a single sheet from a volume of sheets in a workbook No News Microsoft Excel Worksheet Functions 12 1st Jul 2006 05:29 AM
Copy and paste data from one sheet to another in a single workbook =?Utf-8?B?U0lUQ0ZhblRO?= Microsoft Excel Programming 0 10th Jun 2006 01:58 PM
copy data in one sheet to multiple sheets in same workbook =?Utf-8?B?QnJpYW5NdWx0aUxhbmd1YWdl?= Microsoft Excel Worksheet Functions 4 27th Jul 2005 07:26 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:50 PM.