|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub Macro1()
Dim MyPath$, MyName$, sh As Worksheet, m&, d As Object
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set d = CreateObject("scripting.dictionary")
For Each sh In Sheets
Set d(sh.Name) = sh
sh.Range("C3:H10000").Clear
Next
MyPath = ThisWorkbook.Path & "\"
MyName = Dir(MyPath & "*.xls")
Do While MyName <> ""
If MyName <> ThisWorkbook.Name Then
m = m + 1
With GetObject(MyPath & MyName)
For Each sh In .Sheets
If d.Exists(sh.Name) Then
If m = 1 Then
sh.UsedRange.Copy d(sh.Name).[a2]
Else
sh.UsedRange.Offset(1).Copy d(sh.Name).Range("e" & Rows.Count).End(xlUp).Offset(1, -4)
End If
End If
Next
'.Close False
End With
End If
MyName = Dir
Loop
Application.ScreenUpdating = True
Application.DisplayAlerts = 1
End Sub
|
|