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
Bookmarks