Closed Thread
Results 1 to 7 of 7

Macro to create a new worksheet at each change in data

  1. #1
    Registered User
    Join Date
    07-15-2010
    Location
    canada
    MS-Off Ver
    Excel 2007
    Posts
    3

    Macro to create a new worksheet at each change in data

    Hi,
    am hoping someone can help with this? I have been searching for a solution for a long time now.

    What I need to come up with is a macro that will create a new worksheet at each change in Data.

    Ie)
    I have a worksheet full of data, and at each change in the data of column A I would like the a new worksheet created within the same workbook. Something to the effect of:

    Column A
    bill
    bill
    bill
    Jack
    Jack
    Dave
    Dave
    Dave
    Dave

    The macro would take the above data, and create three additional worksheets. 1 with all the rows related to bill, one with the rows related to Jack, and one for Dave. What I am finding difficult to account for is the fact the data in column A can change. For example, in the above list "bill" appears 3 times. But in actuality "bill" could have any number of rows of data.

    anyone have any ideas?

    thanks

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

    Re: Macro to create a new worksheet at each change in data

    I have a macro that may be "ready to use" for parsing rows of data from one sheet to many sheets named for the same values.It not only can parse the rows, it can create the sheets if they are missing.

    There's a sample workbook so you can test it and see it is pretty much exactly what you've described above.
    _________________
    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!)

  3. #3
    Registered User
    Join Date
    07-15-2010
    Location
    canada
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Macro to create a new worksheet at each change in data

    that's great. Looks pretty close to what I am looking for. Thanks.
    The only things I need to modify and I am not sure how are:

    1) I have header information in rows 1-9. and then the data fields names in row 10.
    So row 1-9 needs to copy to every new worksheet. This I can figure out. But the Macro then needs to start as of row 10. In your example it starts with row 2. This sounds like it should be an easy modification, just not sure where to do this in the code. How do I tell it to start with row A10 instead of A2 and then paste on the new worksheet into rows starting with A10?

    2) At the very bottom of the data I have another row of data in the last row of the master worksheet. This would also need to be copied over to the bottom of each new spreadsheet. Also sounds like it should be a simple mod, just not sure how to do this.


    thanks

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

    Re: Macro to create a new worksheet at each change in data

    Sound like you need to change the vTitles to "A9:ED9"...

    Next, the "customize this section"...sounds like you just want everything from A1 down to the bottom of the filtered data, actually simpler than my code...
    Please Login or Register  to view this content.


    These are some very specific tweaks. If they don't work, post a sample workbook so we can test these things together. Click GO ADVANCED and use the paperclip icon to post up a desensitized copy of your workbook.

  5. #5
    Registered User
    Join Date
    07-15-2010
    Location
    canada
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Macro to create a new worksheet at each change in data

    Thanks for your help.

    The initial macro you sent me is pretty much perfect, in that it does almost exactly what I am looking for, so I don't want to lose any of those features. I just need to figure out how to allow for:

    1) There is common data that needs to be on the top of each worksheet. And
    2) There is a row of common data (summation in this case) that needs to go at the end of the pasted data on each worksheet.


    I can figure out how to copy the common rows of data to each new worksheet (rows 1-9). That is not a problem. What I can't figure out is how to make your formula start "working" with row 9, and then paste the data starting with row 9 on the new worksheets.


    I have attached a very basic sample of what I am talking about. I hope this will help illustrate. In the workbook I have 4 tabs:

    Tab 1 - initial data. This is how the workbook would start out. The macro would be run here to end up with the other three tabs.

    Tabs - Bill, Dave, and Eugene.. These wouldn't be there. These are just to show what I am hoping the end results would be like.
    As you can see, this is almost identical to the initial macro you sent me, the differences being the header information that gets copied over, and the summation row at the bottom of the data on the new worksheets.

    Thanks for your help.
    Attached Files Attached Files
    Last edited by that guy; 07-15-2010 at 11:09 PM.

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

    Re: Macro to create a new worksheet at each change in data

    1) There needs to be a complete list of answers in column A, list the sales manager for each row, keep it simple. Do you really even need this column? Something to think about.

    2) In the totals row, you should use the SUBTOTAL() formula instead of SUM(). SUBTOTAL() will adjust its own answers in relation to how many rows are visible in a filtered list.

    3) In the totals row, there needs to be at least one cell that is empty so we can look UP through that column to see how many rows of data are visible not counting the totals row. I've left column B cell empty so we can also get a clean list of values in column B for the sheet names, moving the TOTAL cell eliminates the need to exclude the word "Total" from our sheetname list.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    11-20-2007
    Location
    Menlo Park, CA
    MS-Off Ver
    Office 2019 Pro Plus
    Posts
    33

    Re: Macro to create a new worksheet at each change in data

    Working on a list that has about 250k rows. The code errors out at:

    Please Login or Register  to view this content.
    If I use on 10 lines ,it works. I tried trimming to 60k, but still the same problem. Anyway to get around this, what is the max? Thanks for the help.

Closed 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