+ Reply to Thread
Results 1 to 5 of 5

Copy several sheets in the same workbook to new workbook

  1. #1
    Registered User
    Join Date
    02-09-2007
    Location
    India
    Posts
    5

    Copy several sheets in the same workbook to new workbook

    Hi,

    I need to copy the contents of the all sheets in a single workbook to a new workbook..

    if you could provide me some code, that would be of much use.

    thanks,
    srikanth

  2. #2
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    Make sure the book you are copying from is the active book or replace Set wbAct = ActiveWorkbook
    with
    Set wbAct = Workbooks("Book1.xls")
    change book name as required



    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    02-09-2007
    Location
    India
    Posts
    5
    Thanks Mudraker,

    But the sheets are added as new sheets in that workbook, would it be possible to update the sheets that are already in that workbook

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Srikanthan,

    Here is a macro to copy the Workbook. The copy will be saved on the same drive and in the same folder as the ActiveWorkbook.

    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  5. #5
    Registered User
    Join Date
    02-09-2007
    Location
    India
    Posts
    5
    Thanks Leith,

    I beleive my query has been misunderstood, to make it clear.. I have a work book say sourcle.xls which has 3 sheets.. I need to copy the contents of all the three sheets in to a single sheet in a separate workbook..

    I have framed up a code as below.. can you please help with the code for copying the sheets alone..
    NOTE : Sheets should not be added as new one...

    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 nwe workbook and copies the contents as new sheets.. I want the new workbook to have single sheet with all the contents of source.xls..

    Hope you understand now, sorry for the confusion..

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1