There is a File, about 930000 lines, it is required to divide it into ~ 93 EXEL files of 10,000 lines each. Below is the script, but it does not work.
Sub Test() Dim currentRows As Long, sourceCol As Long, LastRow as Long Dim currentRowValue As String, sourcews As String, rows2 As Long Dim sheetName As String, Исходная As Excel.Workbook, Конечная As Excel.Workbook Set Исходная = ActiveWorkbook sourcews = ActiveSheet.Name sourceCol = 1 RowCoun = Cells(Rows.Count, sourceCol).End(xlUp).Row file2 = 1 МакросКнига ("C:\1\Moscow_Samara" & file2 & ".xls") Set Конечная = Workbooks.Open("C:\1\Moscow_Samara" & file2 & ".xls") For currentRow = 1 To RowCount rows2 = rows2 + 1 currentRowValue = Исходная.Cells(currentRow, sourceCol).Value If Not (IsEmpty(currentRowValue) or currentValue = "") Then Конечная.Worksheets(sheetName).Select LastRow = Cells(Конечная.Rows.Count, sourceCol).End(xlUp).Row If LastRow = 1 And rows2 = 1 Then LastRow = 0 Range(Конечная.Cells(LastRow + 1, 1), Конечная.Cells(LastRow + 1, 1)) _ .PasteSpecial Paste:=xlPasteValues Исходная.WorkSheets(sourcews).Activate End If If rows2 = 10000 Then Конечная.Close SaveChanges:=True file2 = file2 + 1 rows2 = 0 sheetName = "Финиш" & file2 МакросКнига ("C:\1\Moscow_Samara" & file2 & ".xls") Set Конечная = Workbooks.Open("C:\1\Moscow_Samara" & file2 & ".xls") End If Next End Sub Sub МакросКнига (FName As String) ActiveWorkbook.SaveAs FileName: = FName, FileFormat:= _ xlNormal, Password:="", ReadOnlyRecommended:= False _ , CreateBackup:=False EndSub