+ Reply to Thread
Results 1 to 10 of 10

create multiple workbooks from a single workbook

  1. #1
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,176

    create multiple workbooks from a single workbook

    On a weekly basis, I receive a single worksheet in a workbook that contains ~30,000 rows of product sales.

    Row one contains column headings that is unique to all other rows. Column A contains the store number that sold the product. There are ~50 unique store numbers.

    I am trying to create a macro that will break the report up into seperate workbooks.

    For example, assume in column A there are 30 rows of data for 3 different store numbers (say store 112, 386, & 798, each with 10 rows of data). I want to create 3 new workbooks and include the same column heading for each. For example, name new workbooks as follows: "Store 112", "Store 386", "Store 798".

    I am hoping this is possible. Thank you in advance for any commnets.
    Last edited by maacmaac; 06-05-2009 at 11:19 AM.

  2. #2
    Registered User
    Join Date
    04-21-2009
    Location
    Melbourne,Australia
    MS-Off Ver
    Excel 2003,2007
    Posts
    34

    Re: create multiple workbooks from a single workbook

    See the attached - I expect that its very close to what you are looking for.
    Attached Files Attached Files

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: create multiple workbooks from a single workbook

    This was fun to write. It will create a temp sheet, create a list of store numbers, then make and save of workbooks for each store in the default directory. Give it a whirl. When you're done, look in your directory for all the workbooks.
    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 06-04-2009 at 01:51 PM. Reason: Sheet removed...see below for latest version
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,176

    Re: create multiple workbooks from a single workbook

    The code is awesome but how can I preserve the formatting of sheet 1 to all new sheets created (i.e., I want column width, alignment, cell formatting, page setup, etc. to be the same)?

    Thanks

    BTW, I ended up using JBeaucaire's code but both solutions work.

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: create multiple workbooks from a single workbook

    Hm...I guess that's doable. I would need to see a sample sheet to test on, one with at least a store or two sample data and all your desired formatting.

  6. #6
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,176

    Re: create multiple workbooks from a single workbook

    JB,

    Attached two files

    First file is sample data with code.
    Second file "Store 118" is desired output

    Basically, the desired output sheet is formatted in the same exact manner as the sample data (same column width, page setup w/ page numbers, cell formatting, etc).

    Thanks again for all your comments.

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: create multiple workbooks from a single workbook

    Try this amended code, it appears column widths require a completely separate procedure. Changes highlighted in red:
    Please Login or Register  to view this content.
    Attached Files Attached Files

  8. #8
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,176

    Re: create multiple workbooks from a single workbook

    That did the trick. Thanks for quick response.

  9. #9
    Registered User
    Join Date
    05-07-2013
    Location
    Hong Kong
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: create multiple workbooks from a single workbook

    Excel noob here, I opened the examples but couldn't get it to work. Using Excel 2010, what did I do wrong?

  10. #10
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: create multiple workbooks from a single workbook

    No way for us to know that.

    Here's the final published macro for taking the data from a single sheet and creating separate workbooks based on the values in a specified column.

    ===========
    'SHEET1 TO MANY WORKBOOKS
    Here's a macro for parsing rows of data from one sheet to many workbooks based on one column, workbooks named for the same values in that column.My macro names the workbooks for values in the column PLUS today's date, you can take a stab at removing the date part...or leave it in, it's a good technique.
    Last edited by JBeaucaire; 12-27-2019 at 10:07 PM.

+ 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