|
发表于 2012-3-31 16:12
|
显示全部楼层
本楼为最佳答案
Sub subM()
Application.ScreenUpdating = False
Set D = CreateObject("scripting.dictionary")
Arr = Range("A2:B" & Range("A65536").End(3).Row)
ALL = Arr(1, 2)
For i = 2 To UBound(Arr)
D(Arr(i, 1)) = D(Arr(i, 1)) + Arr(i, 2)
Next
PathName = ThisWorkbook.Path & "\*.xls"
dirna = Dir(PathName)
Do While dirna <> ""
If dirna <> ActiveWorkbook.Name Then
Set SourceBook = Workbooks.Open(ThisWorkbook.Path & "\" & dirna, 0, True)
With SourceBook.Worksheets("在职")
For Each c In .Range("B2:S2")
If c.Value Like "*失业*" Then
x = c.Column
End If
Next c
Arr = .Range("A4:P" & Range("A65536").End(3).Row)
End With
For i = 2 To UBound(Arr)
If Not Arr(i, 1) Like "*合计*" Then D(Arr(i, 2)) = D(Arr(i, 2)) + Arr(i, x)
ALL = ALL + Arr(i, x)
Next
SourceBook.Close False
End If
dirna = Dir
Loop
Range("A3:B1000").ClearContents
Range("A3").Resize(D.Count, 1) = Application.Transpose(D.KEYS)
Range("B3").Resize(D.Count, 1) = Application.Transpose(D.ITEMS)
Range("B2") = ALL
Application.ScreenUpdating = True
End Sub
|
|