|
Sub hz()
Application.ScreenUpdating = False
Set sh = ThisWorkbook.ActiveSheet
ar = sh.Range("a1:m1000")
Set d = CreateObject("scripting.dictionary")
Set dc = CreateObject("scripting.dictionary")
For j = 2 To UBound(ar, 2)
If Trim(ar(1, j)) <> "" Then
d(Trim(ar(1, j))) = j
End If
Next j
f = Dir(ThisWorkbook.Path & "\" & sh.Name & "年\*.xls*")
n = 1
Do While f <> ""
Set wb = Workbooks.Open(ThisWorkbook.Path & "\" & sh.Name & "年\" & f, 0)
With wb.Worksheets("水果")
ws = .Cells(Rows.Count, 1).End(xlUp).Row
br = .Range("a1:c" & ws)
m = d(Trim(br(1, 2)))
If m <> "" Then
For i = 2 To UBound(br)
If Trim(br(i, 2)) <> "" Then
If Not dc.exists(Trim(br(i, 2))) Then
n = n + 1
ar(n, 1) = br(i, 2)
ar(n, m) = br(i, 3)
dc(Trim(br(i, 2))) = n
ElseIf dc.exists(Trim(br(i, 2))) Then
t = dc(Trim(br(i, 2)))
ar(t, m) = br(i, 3)
End If
End If
Next i
End If
End With
wb.Close False
f = Dir
Loop
sh.[a1].Resize(n, UBound(ar, 2)) = ar
Application.ScreenUpdating = True
End Sub
|
评分
-
2
查看全部评分
-
|