Saeed Rasool Afridi
New Member
- Joined
- Nov 14, 2017
- Messages
- 5
Code:
Sub test()
Dim lastRow As Long, myRow As Long, myBook As Workbook
lastRow = ThisWorkbook.Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row
For myRow = 2 To lastRow Step 900
Set myBook = Workbooks.Add
ThisWorkbook.Sheets("Sheet1").Rows(myRow & ":" & myRow + 899).EntireRow.Copy myBook.Sheets("Sheet1").Range("A1")
Next myRow
End Sub
Dom
Hi, I used a small script from a thread almost 9 years old. It helped me but the last sheet the macro tried to create, gave me an error which made me conclude, that the remaining data did not have sufficient rows in it.
My data has 1048576 rows in it and I had the code to create new sheets every 40,000 rows, the last sheet was blank because 2576 rows were available instead of 40,000.
I also need the headers' row to show on every new sheet created.
Can anyone please help?
Sub test()
Dim lastRow As Long, myRow As Long, myBook As Workbook
lastRow = ThisWorkbook.Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row
For myRow = 2 To lastRow Step 900
Set myBook = Workbooks.Add
ThisWorkbook.Sheets("Sheet1").Rows(myRow & ":" & myRow + 899).EntireRow.Copy myBook.Sheets("Sheet1").Range("A1")
Next myRow
End Sub
Dom
Hi, I used a small script from a thread almost 9 years old. It helped me but the last sheet the macro tried to create, gave me an error which made me conclude, that the remaining data did not have sufficient rows in it.
My data has 1048576 rows in it and I had the code to create new sheets every 40,000 rows, the last sheet was blank because 2576 rows were available instead of 40,000.
I also need the headers' row to show on every new sheet created.
Can anyone please help?