Sub SplitDataIntoMultipleFilesWithSingleHeader() Dim wsSource As Worksheet Set wsSource = ThisWorkbook.Sheets(1) ' 원본 시트 설정 Dim rowCount As Long rowCount = wsSource.Cells(wsSource.Rows.Count, "A").End(xlUp).Row ' A열에서 데이터가 있는 마지막 행 찾기 Dim filesNeeded As Integer filesNeeded = 25 ' 생성할 파일 수 Dim rowsPerFile As Long rowsPerFile = Round((rowCount - 1) / filesNeeded, 0) ' 파일 당 행 수, 제목 줄 제외 Dim startRow As Long Dim endRow As Long Dim fileNumber As Integer Application.ScreenUpdating = False For fileNumber = 1 To filesNeeded startRow = ((fileNumber - 1) * rowsPerFile) + 2 ' 제목 줄 다음부터 시작 If fileNumber = filesNeeded Then endRow = rowCount ' 마지막 파일은 남은 모든 행을 포함 Else endRow = startRow + rowsPerFile - 1 End If ' 새 워크북 생성 및 데이터 복사 Dim wbNew As Workbook Set wbNew = Workbooks.Add wsSource.Rows("1:1").Copy Destination:=wbNew.Sheets(1).Rows("1:1") ' 제목 줄 복사 If endRow >= startRow Then ' 데이터가 있을 경우에만 복사 wsSource.Range(wsSource.Rows(startRow), wsSource.Rows(endRow)).Copy Destination:=wbNew.Sheets(1).Rows("2") End If ' 파일 저장 Dim fileName As String fileName = ThisWorkbook.Path & "\국어 답안_" & fileNumber & ".xlsx" wbNew.SaveAs fileName, XlFileFormat.xlOpenXMLWorkbook wbNew.Close False Next fileNumber Application.ScreenUpdating = True MsgBox filesNeeded & "개의 파일로 분할 완료되었습니다.", vbInformation End Sub