Option Explicit Public Sub CollectAll() Dim ws As Worksheet Dim wbSrc As Workbook Dim files As Variant Dim filePath As Variant Dim lastRow As Long, lastCol As Long, destRow As Long Dim isFirst As Boolean Dim i As Long files = Application.GetOpenFilename( _ FileFilter:="Excel 파일 (*.xlsx; *.xls; *.xlsm), *.xlsx; *.xls; *.xlsm", _ Title:="취합할 엑셀 파일을 선택하세요 (Ctrl/Shift로 여러 개 선택)", _ MultiSelect:=True) If Not IsArray(files) Then MsgBox "선택된 파일이 없습니다.", vbExclamation Exit Sub End If Application.DisplayAlerts = False On Error Resume Next ThisWorkbook.Sheets("취합원가표").Delete On Error GoTo 0 Application.DisplayAlerts = True Set ws = ThisWorkbook.Sheets.Add(Before:=ThisWorkbook.Sheets(1)) ws.Name = "취합원가표" isFirst = True destRow = 1 For i = LBound(files) To UBound(files) filePath = files(i) Set wbSrc = Workbooks.Open(filePath, ReadOnly:=True) With wbSrc.Sheets(1) lastRow = .Cells(.Rows.Count, 1).End(xlUp).Row lastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column If lastRow >= 1 And lastCol >= 1 Then If isFirst Then .Range(.Cells(1, 1), .Cells(lastRow, lastCol)).Copy ws.Cells(destRow, 1) destRow = destRow + lastRow isFirst = False Else If lastRow >= 2 Then .Range(.Cells(2, 1), .Cells(lastRow, lastCol)).Copy ws.Cells(destRow, 1) destRow = destRow + (lastRow - 1) End If End If End If End With wbSrc.Close SaveChanges:=False Next i With ws.Rows(1) .Font.Bold = True .Interior.Color = RGB(220, 235, 245) End With ws.Columns.AutoFit End Sub