+ Reply to Thread
Results 1 to 3 of 3

Split Excel file into multiple files based on number of rows

Hybrid View

kingtut86 Split Excel file into... 01-24-2013, 11:57 AM
jolivanes Re: Split Excel file into... 01-24-2013, 12:24 PM
kingtut86 Re: Split Excel file into... 01-24-2013, 03:38 PM
  1. #1
    Registered User
    Join Date
    01-14-2013
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2007
    Posts
    2

    Split Excel file into multiple files based on number of rows

    Hi,

    I have an excel file containing 9000-10000 rows. I want to split this into multiple files of 1000 rows each.

    There's a small condition to this. Say that the number of records is around 9400 (not exactly 9000 or 10000).Then I want 9 files containing 1000 each and a 10th file with these 400 rows. Basically, if the records increase it should push it to the last file, untill it reaches a 1000 and then create a new file.


    Any help is much appreciated. Thanks a lot!

    - KC

  2. #2
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,692

    Re: Split Excel file into multiple files based on number of rows

    Try this on a copy of your workbook


    Sub Maybe_This()
    Dim j As Long
    Application.ScreenUpdating = False
        For j = 1 To Sheets("sheet1").Cells.SpecialCells(11).Row Step 1000
            Sheets.Add , Sheets(Sheets.Count)
            Sheets("sheet1").Rows(j).Resize(1000).Copy Sheets(Sheets.Count).Cells(1)
        Next
        Sheets("sheet1").Cells.ClearContents    '<---- If you want Sheet1 cleared of contents
        Application.ScreenUpdating = True
    End Sub

  3. #3
    Registered User
    Join Date
    01-14-2013
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Split Excel file into multiple files based on number of rows

    Thanks jolivanes. It works I tested it.

    Is there a way to schedule this to run as and when new records are added or deleted?

+ 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