Excel批量合并表格sheet的代码

Sub多表合并() Dim f$, p$, a, s Application.ScreenUpdating = False Sheet1.UsedRange.Offset(1).ClearContents p = ThisWorkbook.Path & "\" f = Dir(p & "*.xls") Do While Len(f) If f ThisWorkbook.Name Then With workbooks.open(p & f) a = .Sheets(1).Range("A2:K" & .Sheets(1).[a65536].End(3).Row) s = Split(f, ".")(0) .Close False End With Sheet1.Range("A" & .[a65536].End(3).Row + 1).Resize(UBound(a), UBound(a, 2)) = a .Range("L" & .[l65536].End(3).Row + 1).Resize(UBound(a)).Value = s End If f = Dir Loop Application.ScreenUpdating = True End Sub

txt 文件大小:1.31KB