How to split 1 excel file to multipe file

Poliptm

New Member
Joined
Oct 22, 2021
Messages
2
Office Version
  1. 365
  2. 2019
  3. 2013
Platform
  1. Windows
I have large excel file with more than 20.000 rows
I want to seperate every 700 row with same header and formula, and save as to a new file with name like this “file1-700”, “file701-1400”. until end of row,

Any help would be great, really apreciate it
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Try this macro

VBA Code:
Sub Split_data_into_700()

' This macro is created by earthworm

Dim y As Integer

For y = 1 To Range("H4").Value

    Range("A" & 700 * y - 700 + 2 & ":E" & 700 * y + 1).Select  ' A-E is the selected range increase as per your requirement
    Selection.SpecialCells(xlCellTypeVisible).Select
    Selection.Copy
    Workbooks.Add
    Range("A2").Select
    ActiveSheet.Paste
    ChDir "C:\Users\Test\Desktop\Test" ' Change Test to windows username
   
    'Change below Test to Windows Username
    ActiveWorkbook.SaveAs Filename:="C:\Users\Test\Desktop\Test\" & y & ".xlsx", _
    FileFormat:=xlOpenXMLWorkbook
   
   
    Windows("Roaster.xlsb").Activate ' Change Filename to your main file name
    Sheets("Sheet1").Select
    Application.CutCopyMode = False
    Range("A1:E1").Copy
    Windows(y & ".xlsx").Activate
    Range("A1").Select
    ActiveSheet.Paste
    Range("A1").Select
    ActiveWorkbook.Save
    ActiveWorkbook.Close
     
        Next y
     
End Sub
 
Upvote 0
This is main file

Roaster.xlsb
ABCDEFGHIJ
1S.noHeaders 1Headers 2Headers 3Headers 4700
21Insert Data Length20,0001
32Insert Split Length700701
43Total Files281401
54
65
76
87
98
109
1110
1211
1312
Sheet1
Cell Formulas
RangeFormula
H4H4=INT(H2/H3)
 
Upvote 0
A VBA demonstration for starters :​
VBA Code:
Sub Demo1()
  Const L = 700
    Dim Rw As Range, F$, P$, R&
    Set Rw = ActiveSheet.UsedRange.Rows
         F = String$(Len(CStr(Rw.Count)), "0")
         P = ActiveWorkbook.Path & "\File"
         R = 2
    With Application
        .DisplayAlerts = False
        .ScreenUpdating = False
        .SheetsInNewWorkbook = 1
    With Workbooks.Add.Sheets(1)
         Rw(1).Copy .[A1]
    While R <= Rw.Count
         Rw(R).Resize(L).Copy .[A2]
        .Parent.SaveAs P & Format(R, F) & "-" & Format(Application.Min(R + L - 1, Rw.Count), F), 51
         R = R + L
    Wend
        .Parent.Close False
    End With
        .DisplayAlerts = True
        .ScreenUpdating = True
    End With
        Set Rw = Nothing
End Sub
 
Upvote 0
it doesnt run, when i use it, it not function, not getting any message, not hapen
 
Upvote 0
it doesnt run, when i use it, it not function, not getting any message, not hapen
As two people have supplied code, it would help if you said which code you were referring to.
 
Upvote 0

Forum statistics

Threads
1,223,632
Messages
6,173,472
Members
452,516
Latest member
archcalx

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top