ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Split the Worksheet (https://www.excelbanter.com/excel-programming/401891-split-worksheet.html)

mrbalaje

Split the Worksheet
 
I have worksheet which contains 174501 lines of data in it. First line is the
heading, hence actual data is 174500 lines.

I want to split this huge worksheet in to multiple small worksheets of 1000
lines per file with the same heading in the master worksheet.

Thats means 174 worksheets which contains 1000 lines per file and 175th file
contains the remaining 500 lines. Is there any code available to acheive
this. Can you give an example of the code.

Thanks
Balaje

joel

Split the Worksheet
 

Sub splitpage()
PageCount = 1
Set OldSheet = ActiveSheet
With OldSheet
LastRow = .Cells(Rows.Count, "A").End(xlUp).Row
For RowCount = 2 To LastRow Step 1000
Worksheets.Add after:=Sheets(Sheets.Count)
ActiveSheet.Name = .Name & " (" & PageCount & ")"
.Rows(1).Copy Destination:=ActiveSheet.Rows(1)
.Rows(RowCount & ":" & (RowCount + 999)).Copy _
Destination:=ActiveSheet.Rows(2)
PageCount = PageCount + 1
Next RowCount
End With
End Sub
"mrbalaje" wrote:

I have worksheet which contains 174501 lines of data in it. First line is the
heading, hence actual data is 174500 lines.

I want to split this huge worksheet in to multiple small worksheets of 1000
lines per file with the same heading in the master worksheet.

Thats means 174 worksheets which contains 1000 lines per file and 175th file
contains the remaining 500 lines. Is there any code available to acheive
this. Can you give an example of the code.

Thanks
Balaje



All times are GMT +1. The time now is 12:45 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com