|
用VBA解决【多个相同工作簿的汇总】
Sub yhy()
Dim MyFiles, MyPath, wb As Object
MyPath = ThisWorkbook.Path
MyFiles = Dir(MyPath & "\*.xls")
Application.ScreenUpdating = False
Do While MyFiles <> ""
If MyFiles <> ThisWorkbook.Name Then
Set wb = GetObject(MyPath & "/" & MyFiles)
wb.Sheets(1).Range("G6:H38").Copy
ThisWorkbook.Activate
Range("G6").PasteSpecial Paste:=xlPasteValues, Operation:=xlAdd
wb.Sheets(1).Range("C6:D38").Copy
ThisWorkbook.Activate
Range("C6").PasteSpecial Paste:=xlPasteValues, Operation:=xlAdd
wb.Close False
End If
MyFiles = Dir
Loop
Application.ScreenUpdating = True
End Sub |
|