Kod:
Sub SplitWorkbookToCSV()
Dim srcWs As Worksheet
Dim newWb As Workbook
Dim chunkSize As Long: chunkSize = 350
Dim lastRow As Long
Dim startRow As Long, endRow As Long
Dim partIndex As Long
Dim baseName As String, folderPath As String, filePath As String
Set srcWs = ThisWorkbook.Sheets(1)
lastRow = srcWs.Cells(srcWs.Rows.Count, "A").End(xlUp).Row
If lastRow = 0 Then
MsgBox "Veri bulunamadı!", vbExclamation
Exit Sub
End If
baseName = Left(ThisWorkbook.Name, InStrRev(ThisWorkbook.Name, ".") - 1)
folderPath = ThisWorkbook.Path
If Right(folderPath, 1) <> "\" Then folderPath = folderPath & "\"
Application.ScreenUpdating = False
Application.DisplayAlerts = False
partIndex = 0
For startRow = 1 To lastRow Step chunkSize
partIndex = partIndex + 1
endRow = startRow + chunkSize - 1
If endRow > lastRow Then endRow = lastRow
Set newWb = Workbooks.Add(xlWBATWorksheet)
srcWs.Rows(startRow & ":" & endRow).Copy _
Destination:=newWb.Sheets(1).Rows(1)
filePath = folderPath & "ÖIŞIK-2025" & "_" & _
Format(partIndex, "00") & ".csv"
newWb.SaveAs Filename:=filePath, _
FileFormat:=xlCSV, _
CreateBackup:=False, local:=True
newWb.Close SaveChanges:=False
Next startRow
Application.DisplayAlerts = True
Application.ScreenUpdating = True
MsgBox "Toplam " & partIndex & " dosya oluşturuldu.", vbInformation
End Sub
Her sayfanın ilk satırına sütun başlıklarını yazmak konusunda yardım rica ediyorum.