+ Reply to Thread
Results 1 to 22 of 22

Splitting a worksheet into separate worksheets based on a keyword in a cloumn

  1. #1
    Registered User
    Join Date
    06-26-2013
    Location
    Northern Ireland
    MS-Off Ver
    Excel 2003, 07, 10
    Posts
    92

    Splitting a worksheet into separate worksheets based on a keyword in a cloumn

    I need to split a worksheet based on a keyword in a column. There are 9000 rows and it takes around 3 hours to do this manually. I have code that splits the worksheets but I will have to do this 18 times and it will take too long. Here is my code for splitting worksheet. I need to implement this into a loop to loop 18 times for 18 different keywords but don't know how. Very new to VB and macros

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by boomboomblock; 06-26-2013 at 11:22 AM.

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Splitting a worksheet into separate worksheets based on a keyword in a cloumn

    Use auto-filter, or better attach your sample. To attach a sample, go to advance then attachment.

  3. #3
    Registered User
    Join Date
    06-26-2013
    Location
    Northern Ireland
    MS-Off Ver
    Excel 2003, 07, 10
    Posts
    92

    Re: Splitting a worksheet into separate worksheets based on a keyword in a cloumn

    I need to use a macro so that it is full automated. I have provided some dummy data in the attachment, my spreadsheet is over 9000 rows long and there are 18 sections I must extract. Imagine this data on a much larger scale and they all need to be split into indivudual sheets for analysis purposes. Unfortunately I don't think it is as easy as simply putting an auto-filter in
    Attached Files Attached Files

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Splitting a worksheet into separate worksheets based on a keyword in a cloumn

    Put a header in A1, eg AREA and try this code.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  5. #5
    Registered User
    Join Date
    06-26-2013
    Location
    Northern Ireland
    MS-Off Ver
    Excel 2003, 07, 10
    Posts
    92

    Re: Splitting a worksheet into separate worksheets based on a keyword in a cloumn

    That seems to be working for that problem hopefully I can use it on my other table! Thanks a lot Norie and AB33

  6. #6
    Registered User
    Join Date
    06-26-2013
    Location
    Northern Ireland
    MS-Off Ver
    Excel 2003, 07, 10
    Posts
    92

    Re: Splitting a worksheet into separate worksheets based on a keyword in a cloumn

    The code is making new sheets with the names I need on them but doesn't seem to be pulling all the information out of the original sheet onto my new ones

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644
    It seemed to work fine with the sample workbook.

    A new worksheet was created for each Area and the data for each Area was copied to the appropriate sheet.

    What's different about the sheet you are trying it on?

  8. #8
    Valued Forum Contributor
    Join Date
    03-21-2013
    Location
    cyberia
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Splitting a worksheet into separate worksheets based on a keyword in a cloumn

    alternative suggestion?
    Please Login or Register  to view this content.

  9. #9
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Splitting a worksheet into separate worksheets based on a keyword in a cloumn

    Try the attached.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    06-26-2013
    Location
    Northern Ireland
    MS-Off Ver
    Excel 2003, 07, 10
    Posts
    92

    Re: Splitting a worksheet into separate worksheets based on a keyword in a cloumn

    Yeah it worked fine for the sample sheet. These are some of the headings I will be using in my actual sheet. There are also around 9000 rows for the document I want split. I unfortunately cannot send the full document as it has names of customers etc on it
    Attached Files Attached Files

  11. #11
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Splitting a worksheet into separate worksheets based on a keyword in a cloumn

    I think works with your sample, but need to adjust the headings. I have the heading in row and goes 4 columns across. On the word attached, I think your heading is in row 5, or 6 and stretches up to column M. Please confirm if I am right and will adjust my code.

  12. #12
    Registered User
    Join Date
    06-26-2013
    Location
    Northern Ireland
    MS-Off Ver
    Excel 2003, 07, 10
    Posts
    92

    Re: Splitting a worksheet into separate worksheets based on a keyword in a cloumn

    I need to sort it by column A. My headings go to column R but I was unable to show that as it was too big for the word document as it was too big

  13. #13
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Splitting a worksheet into separate worksheets based on a keyword in a cloumn

    Where is the heading? Is it in row 5, or 6?

  14. #14
    Registered User
    Join Date
    06-26-2013
    Location
    Northern Ireland
    MS-Off Ver
    Excel 2003, 07, 10
    Posts
    92

    Re: Splitting a worksheet into separate worksheets based on a keyword in a cloumn

    The heading is in row 6

  15. #15
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Splitting a worksheet into separate worksheets based on a keyword in a cloumn

    I am not sure what do you mean by you want to sort by column A. I thought we are creating tabs based on column A. If this is not the case, it is a wrong code.
    Attached Files Attached Files

  16. #16
    Registered User
    Join Date
    06-26-2013
    Location
    Northern Ireland
    MS-Off Ver
    Excel 2003, 07, 10
    Posts
    92

    Re: Splitting a worksheet into separate worksheets based on a keyword in a cloumn

    Yes, sorry that's what I meant. It is doing the job I want it to do in my exampleBook but it is not working for my other document. The other document is larger and has more columns than my exampleBook

  17. #17
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Splitting a worksheet into separate worksheets based on a keyword in a cloumn

    I have added another code which could accommodate any columns and rows size and is much faster.
    Attached Files Attached Files

  18. #18
    Registered User
    Join Date
    06-26-2013
    Location
    Northern Ireland
    MS-Off Ver
    Excel 2003, 07, 10
    Posts
    92

    Re: Splitting a worksheet into separate worksheets based on a keyword in a cloumn

    Thanks, which macro is it, alice or createnames

  19. #19
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Splitting a worksheet into separate worksheets based on a keyword in a cloumn

    alice and name of the module is latestmod.

  20. #20
    Registered User
    Join Date
    06-26-2013
    Location
    Northern Ireland
    MS-Off Ver
    Excel 2003, 07, 10
    Posts
    92

    Re: Splitting a worksheet into separate worksheets based on a keyword in a cloumn

    Thanks AB33, it works a treat. Cheers everyone for all their help, very much appreciated!

  21. #21
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Splitting a worksheet into separate worksheets based on a keyword in a cloumn

    You are welcome!

    Could you please now close (Mark) this thread as solved? Go to the top right-hand side of this page, choose "Thread Tools" from the menu, then select "solved" from the drop down menu.

  22. #22
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Splitting a worksheet into separate worksheets based on a keyword in a cloumn

    The code I posted should work for any no of fields/columns as long as you put a heading in A1 which can easily be done with code.

    If the headings aren't in row 1 then there would need some further, small, adjustments.

    Here's the updated code.
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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