|
原帖由 puresway 于 2011-2-12 22:19 发表
都怪我没表达清楚,这是附件,请前辈看下
Sub Macro1()
Dim d As Object, dic As Object, ds As Object, arr, sh As Worksheet, MyPath$, MyName$, i&, m%
Set sh = ActiveSheet
Set d = CreateObject("scripting.dictionary")
Set dic = CreateObject("scripting.dictionary")
Set ds = CreateObject("scripting.dictionary")
ds("A型") = 0
ds("B型") = 1
arr = Sheets("销售人员信息").[a1].CurrentRegion
For i = 2 To UBound(arr)
dic(arr(i, 2)) = arr(i, 1)
Next
arr = Range("A4:A" & Range("A65536").End(xlUp).Row)
ReDim brr(1 To UBound(arr), 2 To 256)
For i = 1 To UBound(arr)
If dic.Exists(arr(i, 1)) Then d(dic(arr(i, 1))) = i
Next
Application.ScreenUpdating = False
[b1:iv1].ClearContents
[a1].CurrentRegion.Offset(3, 1).ClearContents
MyPath = ThisWorkbook.Path & "\"
MyName = Dir(MyPath & "*.xls")
Do While MyName <> ""
If MyName <> ThisWorkbook.Name Then
m = m + 2
sh.Cells(1, m) = "文件" & Split(MyName, ".")(0)
With GetObject(MyPath & MyName)
arr = .Sheets(1).[a1].CurrentRegion
.Close False
End With
For i = 2 To UBound(arr)
If d.Exists(arr(i, 4)) And ds.Exists(arr(i, 2)) Then brr(d(arr(i, 4)), m + ds(arr(i, 2))) = brr(d(arr(i, 4)), m + ds(arr(i, 2))) + arr(i, 3)
Next
End If
MyName = Dir
Loop
[b4].Resize(UBound(brr), m) = brr
Application.ScreenUpdating = True
MsgBox "ok"
End Sub |
|