|
发表于 2012-3-31 08:10
|
显示全部楼层
本楼为最佳答案
本帖最后由 zjdh 于 2012-3-31 08:12 编辑
Sub subM()
Application.ScreenUpdating = False
Set D = CreateObject("scripting.dictionary")
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 |
|