+ Reply to Thread
Results 1 to 4 of 4

Excel VBA - Split rows of data into multiple workbooks based on cell value

Hybrid View

DoodlesMama Excel VBA - Split rows of... 03-26-2015, 02:34 PM
PCI Re: Excel VBA - Split rows of... 03-26-2015, 03:23 PM
alansidman Re: Excel VBA - Split rows of... 03-26-2015, 03:35 PM
alansidman Re: Excel VBA - Split rows of... 03-26-2015, 03:35 PM
  1. #1
    Registered User
    Join Date
    09-05-2012
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2013
    Posts
    71

    Excel VBA - Split rows of data into multiple workbooks based on cell value

    Hello,
    I have a daily report that's split by 3 or 4 people for processing. I can create an input message box or cell with a formula to count and divide the data, but I am unsure of how to create code that will execute the split based on all the factors I've listed below.

    Factors:
    • The number of rows and people can vary daily
    • Macro needs to count the number of data rows, divide it equally then split into multiple workbooks.
    • The data range is dynamic and can be quite large, anywhere from 7k to over 10k rows.
    • Column A is fine for counting # of rows - named range = UNIT_ID
    • Entire data range (Col. A-AX) has a named range = DATA_1
    • Header row is Row 1


    Bonus request: After the data is processed, it will then need to be combined back into one sheet.

    Can anyone offer a solution please?

  2. #2
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,085

    Re: Excel VBA - Split rows of data into multiple workbooks based on cell value

    Cross post see
    - Battle without fear gives no glory - Just try

  3. #3
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,698

    Re: Excel VBA - Split rows of data into multiple workbooks based on cell value

    Your post does not comply with Rule 8 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,698

    Re: Excel VBA - Split rows of data into multiple workbooks based on cell value

    Try this:

    Option Explicit
    
    Sub Divide()
        Dim lr As Long
        lr = Range("A" & Rows.Count).End(xlUp).Row
        Dim p As Long
        p = InputBox("how many users?")
        Dim splt As Long
        splt = Int(lr / p) + 1
        MsgBox (splt)
        Dim T1 As Workbook, T2 As Workbook, T3 As Workbook, T4 As Workbook
        Set T1 = Workbooks("Tar1.xlsx")
        Set T2 = Workbooks("Tar2.xlsx")
        Set T3 = Workbooks("Tar3.xlsx")
        Set T4 = Workbooks("Tar4.xlsx")
        
        Range("A1:AX1").Copy T1.Sheets("Sheet1").Range("A1")
        Range("A1:AX1").Copy T2.Sheets("Sheet1").Range("A1")
        Range("A1:AX1").Copy T3.Sheets("sheet1").Range("A1")
        Range("A1:AX1").Copy T4.Sheets("Sheet1").Range("A1")
        Range("A2:AX" & splt - 1).Copy T1.Sheets("Sheet1").Range("A2")
        Range("A" & splt & ":AX" & splt * 2).Copy T2.Sheets("Sheet1").Range("A2")
        Range("A" & splt * 2 & ":AX" & splt * 3).Copy T3.Sheets("Sheet1").Range("A2")
        Range("A" & splt * 3 & ":AX" & splt * 4).Copy T4.Sheets("Sheet1").Range("A2")
        Application.CutCopyMode = False
        
    End Sub

+ 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. Split Row Into Multiple Rows based on Count of Data
    By bchilme in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-22-2014, 05:58 PM
  2. Replies: 1
    Last Post: 04-20-2014, 02:48 PM
  3. [SOLVED] Split workbook into multiple workbooks based on data
    By rlsublime in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-07-2014, 12:26 AM
  4. Split Excel Spreadsheet Data Into New Workbooks based on page breaks
    By sarndt01 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-23-2013, 02:14 AM
  5. Row split in to multiple rows based on cell data
    By bosuck in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-08-2011, 05:30 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