|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 取数()
Application.ScreenUpdating = False
Dim d As Object
Set d = CreateObject("scripting.dictionary")
Set sh = ThisWorkbook.Worksheets(1)
r = sh.Cells(Rows.Count, 1).End(xlUp).Row
sh.Range("c2:f" & r) = Empty
ar = sh.[a1].CurrentRegion
For i = 2 To UBound(ar)
If Trim(ar(i, 1)) <> "" And Trim(ar(i, 2)) <> "" Then
d(Trim(ar(i, 1))) = ""
zf = Trim(ar(i, 1)) & "|" & Trim(ar(i, 2))
d(zf) = i
End If
Next i
For j = 3 To UBound(ar, 2)
If Trim(ar(1, j)) <> "" Then
d(Trim(ar(1, j))) = j
End If
Next j
For Each k In d.keys
mc = "唐" & Format(k, "dmmmyyyy")
f = Dir(ThisWorkbook.Path & "\" & mc & ".xls*")
If f <> "" Then
Set wb = Workbooks.Open(ThisWorkbook.Path & "\" & f, 0)
For Each sht In wb.Worksheets
rs = sht.Cells(Rows.Count, 2).End(xlUp).Row
br = sht.Range("b1:c" & rs)
n = d(k & "|" & sht.Name)
For i = 2 To UBound(br)
m = d(Trim(br(i, 1)))
If n <> "" And m <> "" Then
ar(n, m) = br(i, 2)
End If
Next i
Next sht
wb.Close False
End If
Next k
sh.[a1].CurrentRegion = ar
Application.ScreenUpdating = True
MsgBox "ok!" |
|