|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub shishi()
Excel.Application.ScreenUpdating = False
Excel.Application.DisplayAlerts = False
Set dic = CreateObject("Scripting.Dictionary")
p = ThisWorkbook.Path & "\"
f = Dir(p & "*.xls*")
Do While f <> ""
If f <> ThisWorkbook.Name Then
Set wb = Workbooks.Open(p & f)
arr = wb.Sheets("汇总3").[a1].CurrentRegion
For i = 2 To UBound(arr)
If arr(i, 2) <> "" Then
If Not dic.exists(arr(i, 2)) Then
dic(arr(i, 2)) = Array(arr(i, 1), arr(i, 2), arr(i, 3), arr(i, 4))
Else
dic.Remove (arr(i, 2))
End If
End If
Next
wb.Close False
End If
f = Dir
Loop
[a1].CurrentRegion.Offset(3).ClearContents
[a3].Resize(dic.Count, 4) = Application.Rept(dic.items, 1)
Excel.Application.DisplayAlerts = True
Excel.Application.ScreenUpdating = True
End Sub |
|