I’ve got a workbook with 90000 lines and three worksheets (Sheet1, Sheet2, Sheet3)
Sheet 1 has the main data (90000 lines)
Sheet 2 has some data
Sheet 3 has some data
What I want is to split the data in sheet 1 into 5000 lines, copy sheet 2 and sheet 3 as it is and then save it as “filename-1”. I want to do this for all lines. I also need the headers in all split files. I want to save this in xml format.
If anyone can help will be great!
I have currently come until here, which splits sheet1 only and does not copy the headers and sheet2 and 3. And does not save it as xml. [ for sample purposes I’ve left this to save after every 5 rows]
Sub Macro1()
Dim rLastCell As Range
Dim rCells As Range
Dim strName As String
Dim lLoop As Long, lCopy As Long
Dim wbNew As Workbook
With ThisWorkbook.Sheets(1)
Set rLastCell = .Cells.Find(What:="*", After:=[A1], SearchDirection:=xlPrevious)
For lLoop = 1 To rLastCell.Row Step 5
lCopy = lCopy + 1
Set wbNew = Workbooks.Add
.Range(.Cells(lLoop, 1), .Cells(lLoop + 5, .Columns.Count)).EntireRow.Copy _
Destination:=wbNew.Sheets(1).Range("A1")
wbNew.Close SaveChanges:=True, Filename:="Chunk" & lCopy & "Rows" & lLoop & "-" & lLoop + 5
Next lLoop
End With
End Sub