+ Reply to Thread
Results 1 to 7 of 7

Split table, based on two criteria, into separate workbooks

  1. #1
    Registered User
    Join Date
    07-10-2012
    Location
    Yorkshire, England
    MS-Off Ver
    Excel 2010
    Posts
    11

    Question Split table, based on two criteria, into separate workbooks

    Hi all,

    I would like to be able to automate the process of splitting up a table and saving these new tables to separate workbooks. I've been asked to do this for my manager at work, and it is a spreadsheet to track employee commissions. All commissions are being stored in the one sheet, for all months and agents, but at the end of each month we need to separate the commissions for each agent for the relevant month.

    I've attached an example spreadsheet that has three columns (the actual spreadsheet records more data): A1, Organisation name; B1, Agent; and C1 Month. The required criteria is the month I need and, if possible, I'd like to have a choice of selecting a specific Agent or selecting all. For example: get the commissions for all Agents for May; or commissions for Agent Tom for June (this would be a bonus, but not essential). The code would need to split the table according to the desired criteria and then save each Agent's commissions into a new workbook with the file name format of "Agent - Month" (i.e. "Tom - May").

    I use Excel 2010, but I'd like it to be compatible with 2007 as well.

    I'd like to thank anyone who attempts to help me with this in advance.... Thanks.
    Attached Files Attached Files

  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: Split table, based on two criteria, into separate workbooks

    This should do it:

    Please Login or Register  to view this content.
    _________________
    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-10-2012
    Location
    Yorkshire, England
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Split table, based on two criteria, into separate workbooks

    Hi Jerry,

    Thanks for that piece of code; it worked great for the test file. However, when I tried to utilise it in the actually workbook it is not working. I believe it is because the 'Agent' and 'Month' columns are in different places. In the actually spreadsheet the 'Agent' column is column D and 'Month' is at F. I changed the code to reflect these changes, but it does not work

    I have also made minor edits to the save location, it now creates a new folder labelled with the month variable. I tested this within the test file, and it worked great; so I know that code is not the problem.

    Would you mind helping me once again?

    The code currently looks like:

    Please Login or Register  to view this content.

  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: Split table, based on two criteria, into separate workbooks

    So I hope we've learned to post sample workbooks that exactly match your actual need...

    Post up that and I'll check your code edits. Make sure the code in in the wb, too.

  5. #5
    Registered User
    Join Date
    07-10-2012
    Location
    Yorkshire, England
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Split table, based on two criteria, into separate workbooks

    I've uploaded the new workbook, with my code edits in place. I appreciate all your help with this

    Thanks
    Attached Files Attached Files

  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: Split table, based on two criteria, into separate workbooks

    Some additional tiny edits:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    07-10-2012
    Location
    Yorkshire, England
    MS-Off Ver
    Excel 2010
    Posts
    11

    Talking Re: Split table, based on two criteria, into separate workbooks

    Fantastic!!! The code now works perfectly

    Thank you for all your help with this.

+ 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