|
楼主 |
发表于 2017-12-29 15:38
|
显示全部楼层
以E列名称为关键字,汇总各个工作薄A列的数量
- Sub 合并当前目录下所有工作簿的全部工作表()
- Set d = CreateObject("scripting.dictionary")
- Set fso = CreateObject("scripting.filesystemobject")
- Application.ScreenUpdating = False
- Set sh = ActiveSheet
- arr = sh.UsedRange
- For j = 2 To UBound(arr)
- d(arr(j, 2)) = arr(j, 1)
- Next j
- For Each f In fso.getfolder(ThisWorkbook.Path).Files
- If InStr(f.Name, "汇总表") = 0 Then
- With Workbooks.Open(f)
- arr = .Sheets(1).UsedRange
- .Close False
- End With
- For j = 3 To 20
- d(arr(j, 5)) = d(arr(j, 5)) + arr(j, 1)
- Next j
- End If
- Next f
- sh.[b2].Resize(d.Count) = WorksheetFunction.Transpose(d.keys)
- sh.[a2].Resize(d.Count) = WorksheetFunction.Transpose(d.items)
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|