+ Reply to Thread
Results 1 to 25 of 25

Copy Each Sheet in Workbook to New Specific Workbook

  1. #1
    Registered User
    Join Date
    09-19-2014
    Location
    Philadelphia,PA
    MS-Off Ver
    2010
    Posts
    54

    Copy Each Sheet in Workbook to New Specific Workbook

    Hi all,

    I have a code that takes all the sheets in my workbook and pastes them each into a new workbook. However, I would like each sheet to paste into Sheet1 of an already existing workbook. Is there anyway to tweak the below code to accomplish this?

    Thank you all so much!

    Please Login or Register  to view this content.

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Copy Each Sheet in Workbook to New Specific Workbook

    Are you saying that your code doesn't already do that?
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Copy Each Sheet in Workbook to New Specific Workbook

    Hi, xladept,

    Are you saying that your code doesn't already do that?
    Copy to an existing workbook and on one worksheet only? According to what I read from the code IŽd say no.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  4. #4
    Registered User
    Join Date
    09-19-2014
    Location
    Philadelphia,PA
    MS-Off Ver
    2010
    Posts
    54

    Re: Copy Each Sheet in Workbook to New Specific Workbook

    Quote Originally Posted by xladept View Post
    Are you saying that your code doesn't already do that?
    No. it copies each sheet to a new workbook, but I need it to copy the cells in each sheet into an existing template workbook that I have created.

  5. #5
    Registered User
    Join Date
    09-19-2014
    Location
    Philadelphia,PA
    MS-Off Ver
    2010
    Posts
    54

    Re: Copy Each Sheet in Workbook to New Specific Workbook

    Holger,

    Yes it does copy the sheets to a workbook, but I need the data in each sheet to copy into a template workbook. Not a new workbook.

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Copy Each Sheet in Workbook to New Specific Workbook

    Oh Duhhh! I didn't read the whole description Thanks for pointing that out Holger and KT I apologise

  7. #7
    Registered User
    Join Date
    09-19-2014
    Location
    Philadelphia,PA
    MS-Off Ver
    2010
    Posts
    54

    Re: Copy Each Sheet in Workbook to New Specific Workbook

    No problem at all!

  8. #8
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Copy Each Sheet in Workbook to New Specific Workbook

    Hi, KT99,

    maybe have a look at WBs to 1 Sheet which might be needed to adapt to your requirement but will surely point the direction.

    Ciao,
    Holger
    Last edited by JBeaucaire; 12-26-2019 at 04:56 PM.

  9. #9
    Registered User
    Join Date
    09-19-2014
    Location
    Philadelphia,PA
    MS-Off Ver
    2010
    Posts
    54

    Re: Copy Each Sheet in Workbook to New Specific Workbook

    I'll give it a look! Thank you, Holger

  10. #10
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Copy Each Sheet in Workbook to New Specific Workbook

    Hi KT,

    In atonement:

    Please Login or Register  to view this content.

  11. #11
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Copy Each Sheet in Workbook to New Specific Workbook

    Hi,m xladept,

    I didn't read the whole description
    Does your code merge all the contents into one sheet (Sheet1) in an exisitng workbook? Please read the request carefully and try to offer code in a way that starters may follow easily. For your approach it would be easier to use SaveAs for a different extension of the workbook or SaveCopyAs for a backup.

    Ciao,
    Holger

  12. #12
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Copy Each Sheet in Workbook to New Specific Workbook

    Hi KT,

    Holger is right and I'm wrong again Sorry, I'll edit for your requirement anon

  13. #13
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Copy Each Sheet in Workbook to New Specific Workbook

    Hi KT,

    See if this works for you:

    Please Login or Register  to view this content.
    *When you replace "Your Book Name" in the code don't forget the ".xlsx" extension
    Last edited by xladept; 10-11-2014 at 04:23 PM.

  14. #14
    Registered User
    Join Date
    09-19-2014
    Location
    Philadelphia,PA
    MS-Off Ver
    2010
    Posts
    54

    Re: Copy Each Sheet in Workbook to New Specific Workbook

    Hey Holger and xladept,

    Sorry for the late responses. But no, my code doesn't merge all the sheets into one sheet. Basically, I have 15,000 lines of data, I have another code that looks for the unique data and places each group of customer codes as its own worksheet in one book (so I end up with 400 different sheets in one workbook). Each sheet is saved as the customer id name (which is what I need). Then, I have a separate excel workbook (named Template.xlsm) with two sheets in it. Sheet 1 of the template.xlsm document is where I want the data from one of the sheets to post. The code would then save the template.xlsm file as that specific customer code. The code needs to loop to do the same thing for each sheet of customer codes. Essentially I will end up with 400 workbooks, with the data from each sheet of customer codes, pasted into sheet one in each workbook.

  15. #15
    Registered User
    Join Date
    09-19-2014
    Location
    Philadelphia,PA
    MS-Off Ver
    2010
    Posts
    54

    Re: Copy Each Sheet in Workbook to New Specific Workbook

    Xladept,

    I get error #9 subscript out of range when I try to run your code.

    Please Login or Register  to view this content.
    is what keeps getting highlighted. I tried every variant of my file name but it still does not work. Do I have to put an additional code in the template to get it to run?

  16. #16
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Copy Each Sheet in Workbook to New Specific Workbook

    You don't include the path in there, and the workbook must be open.
    Remember what the dormouse said
    Feed your head

  17. #17
    Registered User
    Join Date
    09-19-2014
    Location
    Philadelphia,PA
    MS-Off Ver
    2010
    Posts
    54

    Re: Copy Each Sheet in Workbook to New Specific Workbook

    Thank you romperstomper, that worked.

    However, this code pastes each sheets info into sheet1 of the template. I need each sheet in the original workbook to paste into its own template.

    Say there the sheets in the original workbook are named Customer A, Customer B, and Customer C. I need the code to copy the customer A sheet data, into sheet 1 of the template. Save the workbook as Customer A and then exit out. Then the code would loop back and copy the data from customer B, copy the data into a new template workbook, save the workbook as customer B etc.

  18. #18
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Copy Each Sheet in Workbook to New Specific Workbook

    Try something like this:
    Please Login or Register  to view this content.

  19. #19
    Registered User
    Join Date
    09-19-2014
    Location
    Philadelphia,PA
    MS-Off Ver
    2010
    Posts
    54

    Re: Copy Each Sheet in Workbook to New Specific Workbook

    THANK YOU SO MUCH romperstomper!!!!! THAT IS EXACTLY WHAT I NEEDED!

  20. #20
    Registered User
    Join Date
    09-19-2014
    Location
    Philadelphia,PA
    MS-Off Ver
    2010
    Posts
    54

    Re: Copy Each Sheet in Workbook to New Specific Workbook

    Sorry to add something,

    But the macros I have in the template don't copy to the new workbooks created. Is there a quick fix to this? I have a macro that emails each copy to me, and a print option

  21. #21
    Registered User
    Join Date
    09-19-2014
    Location
    Philadelphia,PA
    MS-Off Ver
    2010
    Posts
    54

    Re: Copy Each Sheet in Workbook to New Specific Workbook

    the new workbooks created are .xlsx files where as the template is a macro file (.xlsm).

  22. #22
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Copy Each Sheet in Workbook to New Specific Workbook

    Change this line:
    Please Login or Register  to view this content.
    to this:
    Please Login or Register  to view this content.

  23. #23
    Registered User
    Join Date
    09-19-2014
    Location
    Philadelphia,PA
    MS-Off Ver
    2010
    Posts
    54

    Re: Copy Each Sheet in Workbook to New Specific Workbook

    Perfection, that worked. Thank you, once again, romperstomper.

  24. #24
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Copy Each Sheet in Workbook to New Specific Workbook

    Glad to help.

  25. #25
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Copy Each Sheet in Workbook to New Specific Workbook

    Hi KT,

    Thanks for the rep!

    Please Login or Register  to view this content.

    Whoops! I was answering a post on the first page:\
    Last edited by xladept; 10-13-2014 at 02:24 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Copy Multiple Sheets to New WorkBook but not specific sheet
    By marreco in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-23-2014, 09:36 AM
  2. How to copy Sheet to a new workbook and save to a specific folder
    By moxman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-15-2014, 07:43 PM
  3. copy of sheet from specific workbook to active workbook
    By prabhuduraraj09 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-06-2014, 07:31 AM
  4. [SOLVED] Copy Values From Each Workbook in Folder to a Single Sheet in New Workbook +Workbook names
    By Arsham24 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-21-2012, 07:42 PM
  5. [SOLVED] how to copy a sheet to a specific workbook
    By lm in forum Excel General
    Replies: 1
    Last Post: 10-14-2005, 02:05 PM

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