|
Option Explicit
Sub test()
Dim ar, br, i&, j&, strFileName$, strPath$, dic As Object, strKey$, rngFind As Range
strPath = ThisWorkbook.Path & "\"
strFileName = strPath & "总计划.xlsx"
If Dir(strFileName) = "" Then MsgBox "总计划文件不存在,请检查!", vbExclamation: Exit Sub
Application.ScreenUpdating = False
Set dic = CreateObject("Scripting.Dictionary")
ar = [B5].CurrentRegion.Value
For i = 2 To UBound(ar)
strKey = ar(i, 2) & "|" & ar(i, 3)
dic(strKey) = Array(ar(i, 1), ar(i, 6), ar(i, 5))
Next i
With Workbooks.Open(strFileName, 0)
For j = 0 To dic.Count - 1
br = Split(dic.keys()(j), "|")
On Error Resume Next
With Worksheets(br(0))
Set rngFind = .Cells.Find(br(1), , , xlWhole)
If Not rngFind Is Nothing Then rngFind.Offset(, 1).Resize(, 3).Value = dic.Items()(j)
End With
On Error GoTo 0
Next j
.Close True
End With
Application.ScreenUpdating = True
Beep
End Sub
|
评分
-
1
查看全部评分
-
|