Results 1 to 12 of 12

Macro that exports every X number of sheets into seperate files

Threaded View

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

    Re: Macro that exports every X number of sheets into seperate files

    Give a chance to next code
    The macro is hosted in the file attached and can be used as a toolbox
    The original file (with data )must be loaded in Excel, its name is "OrgFile.xlsx" : Adapt it to your need
    All files prepared are recorded in the same folder as the toolbox (active file) and are named "DestFile" plus an index. If there is some files with the same name they are replaced by the new file.
    Option Explicit
    
    Sub Treat()
    Dim OrgFile As Workbook
    Dim DestFile As Workbook
    Const OrgFileName As String = "OrgFile.xlsx"
    Const DestFileName As String = "DestFile"
    Dim WkPath As String
    Dim WS As Worksheet
    Dim i As Integer
    Dim II As Integer
        Set OrgFile = Workbooks(OrgFileName)
        WkPath = ActiveWorkbook.Path & "\"
        With OrgFile
            For i = 1 To .Worksheets.Count Step 4
                Workbooks.Add
                .Sheets(i).Copy Before:=Sheets(1)
                Application.DisplayAlerts = False
                For II = 2 To Sheets.Count
                    Sheets(II).Delete
                Next
                ActiveWorkbook.SaveAs WkPath & DestFileName & i & ".xlsx"
                ActiveWorkbook.Close
                Application.DisplayAlerts = True
            Next
        End With
    End Sub
    Attached Files Attached Files
    Last edited by PCI; 07-21-2015 at 03:20 PM. Reason: additional info added
    - Battle without fear gives no glory - Just try

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 6
    Last Post: 04-27-2023, 08:20 AM
  2. [SOLVED] Search row and pull column number involving seperate sheets
    By Jon.R in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-20-2013, 04:41 PM
  3. splitting excel workbook into seperate sheets depending on number of rows
    By buketdurusoy in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 12-28-2012, 04:52 PM
  4. [SOLVED] Numbering ROWS sequentially on seperate sheets or files
    By Busybirds in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-27-2012, 12:40 PM
  5. Automatically create and fill sheets and then save as seperate files
    By Focus_Kevin in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-01-2010, 11:26 AM
  6. VBA code to split sheets and save as seperate CSV files
    By mccrimmon in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-01-2008, 01:59 PM
  7. how do i open csv data files into seperate sheets ?
    By zohar81 in forum Excel General
    Replies: 0
    Last Post: 03-13-2008, 10:57 AM
  8. Splitting a workbook's sheets into seperate files
    By Turnipboy in forum Excel General
    Replies: 4
    Last Post: 10-20-2005, 10:05 AM

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