计算机摘录
Sub 合并当前目录下所有工作簿()
Dim Wb As Workbook
Application.ScreenUpdating = False
MyPath = ActiveWorkbook.Path
MyName = Dir(MyPath & "\" & "*.xlsx")
AWbName = ActiveWorkbook.Name
Do While MyName <> ""
If MyName <> AWbName Then
Set Wb = Workbooks.Open(MyPath & "\" & MyName)
c = ThisWorkbook.Sheets("sheet1").UsedRange.SpecialCells(xlCellTypeLastCell).Row
If c = 1 Then '防止合并的工作簿第一行空着
c = 0
End If
ActiveSheet.UsedRange.Copy ThisWorkbook.Sheets("sheet1").Cells(c + 1, 1) '合并工作簿的第一个sheet名字为:sheet1
Wb.Close False
End If
MyName = Dir
Loop
Application.ScreenUpdating = True
MsgBox "已完成"
End Sub