Sub Copy_8000()
Dim r As Long, lastRow As Long, numRows As Long
Dim part As Integer
part = 0
lastRow = 200000
numRows = 8000
For r = 1 To lastRow Step numRows
part = part + 1
Rows(r & ":" & r + numRows - 1).Copy
Workbooks.Add
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWorkbook.SaveAs Filename:="C:\temp\excel\Part_" & part & ".xls", FileFormat:=xlExcel8
ActiveWorkbook.Close savechanges:=False
Next
End Sub
What is the exact error? The code works for me in Excel 2003 and 2007. Help yourself by recording a macro to create a new workbook to show the full syntax of Workbooks.Add and using that in my code.But problem in Workbooks.Add
Sub Copy_8000B()
Dim r As Long, lastRow As Long, numRows As Long
Dim part As Integer
Dim thisSheet As Worksheet
lastRow = 200000
numRows = 8000
part = 0
Set thisSheet = ActiveSheet
For r = 2 To lastRow Step numRows
part = part + 1
Workbooks.Add
thisSheet.Rows(1).Copy Rows(1)
thisSheet.Rows(r & ":" & r + numRows - 1).Copy Rows(2)
ActiveWorkbook.SaveAs Filename:="C:\temp\excel\Part_" & part & ".xls", FileFormat:=xlExcel8
ActiveWorkbook.Close savechanges:=False
Next
End Sub