+ Reply to Thread
Results 1 to 17 of 17

Split Workbook in New Workbooks and Split Workbook into Worksheets

  1. #1
    Registered User
    Join Date
    01-14-2013
    Location
    Derby
    MS-Off Ver
    Excel 2007
    Posts
    28

    Split Workbook in New Workbooks and Split Workbook into Worksheets

    Hi,

    I need macro which will split raw data into new workbooks by column Q (using the Column Q as the new workbook file name ie One, Two, Three etc) and then the data being split into different worksheets (ie A B C etc)

    I have xxx out the data - the data will always run to column AD

    Any help will be greatly appreciated.

    Thank you.

    Row Labels
    Five
    M
    N
    O
    P
    Q
    R
    Four
    K
    L
    T
    U
    V
    X
    Y
    Z
    AA
    One
    A
    B
    C
    D
    E
    F
    G
    Six
    S
    Three
    J
    Two
    H
    I
    Grand Total
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: Split Workbook in New Workbooks and Split Workbook into Worksheets

    Hi gallen6945,

    Try this (noting my comments along the way):

    Please Login or Register  to view this content.
    Regards,

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  3. #3
    Registered User
    Join Date
    01-14-2013
    Location
    Derby
    MS-Off Ver
    Excel 2007
    Posts
    28

    Re: Split Workbook in New Workbooks and Split Workbook into Worksheets

    Hi,

    Many thanks Robert.

    Unfortunately it's debugging on the below -

    lngLastRow = wsSrcTab.Range("A:AD").Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row

    Regards,

    Geoff

  4. #4
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Split Workbook in New Workbooks and Split Workbook into Worksheets

    and then the data being split into different worksheets (ie A B C etc)
    What does this mean...
    Last edited by Sintek; 04-30-2024 at 04:38 AM.
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Split Workbook in New Workbooks and Split Workbook into Worksheets

    gallen6945

    Try the attached.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by jindon; 04-30-2024 at 04:57 AM.

  6. #6
    Registered User
    Join Date
    01-14-2013
    Location
    Derby
    MS-Off Ver
    Excel 2007
    Posts
    28

    Re: Split Workbook in New Workbooks and Split Workbook into Worksheets

    Hi,

    Many thanks - unfortunately it is debugging on the below -

    Set r = ThisWorkbook.Sheets("sheet3").[d1]

    and when I amended it to Sheet1 - it debugs on

    .Columns("q").AdvancedFilter 2, , r, Unique:=True

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Split Workbook in New Workbooks and Split Workbook into Worksheets

    Is that happening to the workbook I attached?

  8. #8
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Split Workbook in New Workbooks and Split Workbook into Worksheets

    Another Option...
    Please Login or Register  to view this content.
    Attached Files Attached Files

  9. #9
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: Split Workbook in New Workbooks and Split Workbook into Worksheets

    Many thanks Robert.

    Unfortunately it's debugging on the below -

    lngLastRow = wsSrcTab.Range("A:AD").Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    I'd say it's because there's no data on the sheet you've assigned to the wsSrcTab variable (I used Sheet1 as an example). Make sure you set the sheet with the data in it to the wsSrcTab variable and try again. It worked for me.

  10. #10
    Forum Expert
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,513

    Re: Split Workbook in New Workbooks and Split Workbook into Worksheets

    Perhab
    Please Login or Register  to view this content.
    Last edited by daboho; 04-30-2024 at 07:19 AM.

  11. #11
    Registered User
    Join Date
    01-14-2013
    Location
    Derby
    MS-Off Ver
    Excel 2007
    Posts
    28

    Re: Split Workbook in New Workbooks and Split Workbook into Worksheets

    Thank you - apologies but debugged here

    .Sort .Columns(17), xlAscending, , , , , , xlYes

  12. #12
    Registered User
    Join Date
    01-14-2013
    Location
    Derby
    MS-Off Ver
    Excel 2007
    Posts
    28

    Re: Split Workbook in New Workbooks and Split Workbook into Worksheets

    Hi, yes it worked on the file you sent but when I used a drive on my company network and the correct raw data - it didn't work - is there a way of doing this without the Pivot Table in Sheet 3 - this was included as a guide as to how many tabs workbooks and worksheets should have been created

  13. #13
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Split Workbook in New Workbooks and Split Workbook into Worksheets

    OK, then try this one.
    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    01-14-2013
    Location
    Derby
    MS-Off Ver
    Excel 2007
    Posts
    28

    Re: Split Workbook in New Workbooks and Split Workbook into Worksheets

    Debugs here now

    .Columns("q").AdvancedFilter 2, , r, Unique:=True

  15. #15
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Split Workbook in New Workbooks and Split Workbook into Worksheets

    Quote Originally Posted by gallen6945 View Post
    Thank you - apologies but debugged here
    .Sort .Columns(17), xlAscending, , , , , , xlYes
    Not with the sample file...Seems all the above code which should work errors for you...
    I am guessing that the file you are testing the code with is NOT the same setup as these sample files we are making use of...

    is there a way of doing this without the Pivot Table in Sheet 3
    My code does just that...


    So...Help us, help you....Have you run the code in the file of post 8

  16. #16
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Split Workbook in New Workbooks and Split Workbook into Worksheets

    Are you sure?

    It is working, so if it is not working at your end, I need to see your workbook.
    Attached Files Attached Files

  17. #17
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Split Workbook in New Workbooks and Split Workbook into Worksheets

    Yep...Post 8 code works with file in Post 16 too...

+ 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] Split One Workbook into Multiple Workbooks
    By billy_t in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-12-2015, 12:13 PM
  2. Split workbook into multiple workbooks with worksheets
    By itgeltugs in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-21-2014, 11:51 PM
  3. Split a workbook into multiple workbooks
    By stewfeed in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-30-2013, 07:15 AM
  4. [SOLVED] Split Macro modification to Split into new Workbooks instead of sheets within one workbook
    By DLSmith in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-13-2012, 08:11 PM
  5. Split a Workbook in to Several Workbooks
    By martinez_pedro in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-23-2010, 12:52 AM
  6. Replies: 0
    Last Post: 09-19-2005, 03: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