|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub test()
Set d = CreateObject("scripting.dictionary")
Set fso = CreateObject("scripting.filesystemobject")
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set sh = ThisWorkbook.Sheets("汇总")
sh.UsedRange.ClearContents
c = 1
For Each f In fso.getfolder(ThisWorkbook.Path).Files
If InStr(f.Name, ThisWorkbook.Name) = 0 Then
With Workbooks.Open(f)
arr = .Sheets(1).UsedRange
.Close False
End With
d.RemoveAll
For j = 2 To UBound(arr)
If Len(arr(j, 15)) > 0 Then
d(arr(j, 15)) = d(arr(j, 15)) + Val(arr(j, 22))
End If
Next j
sh.Cells(1, c) = fso.getbasename(f.Name)
sh.Cells(2, c).Resize(1, 2) = Array("规格", "数量")
If d.Count > 0 Then
Cells(3, c).Resize(d.Count) = WorksheetFunction.Transpose(d.keys)
Cells(3, c + 1).Resize(d.Count) = WorksheetFunction.Transpose(d.items)
End If
c = c + 2
End If
Next
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
|
评分
-
1
查看全部评分
-
|