Sub A() Dim A A = Application.GetOpenFilename(请选择.XLS文件,*.XLS, 1, 温馨提示) If A = False Then Exit Sub End If Workbooks.Open A With ActiveSheet 'ActiveSheet 可以改为sheets(1)或者sheets(“工作表名称”) .Cells.Copy Workbooks(test).Range(A1) '复制到TEST工作簿里,单元个A1里 ActiveWorkbook.Close End With
新建一个汇总表,将汇总表与其他excel文件放在同一文件夹中,在汇总表中写宏: Sub 汇总() a = Dir(ThisWorkbook.Path & \*.xls) On Error Resume Next For i = 1 To 100 If a ThisWorkbook.Name Then Workbooks.Open Filename:=ThisWorkbook.Path & \ & a Workbooks(a).Sheets(1).Copy After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count) Workbooks(a).Close savechanges:=False End If a = Dir Next i End Sub