|
参与一下。。。
- Sub ykcbf() '//2024.6.18
- Set fso = CreateObject("scripting.filesystemobject")
- Set d = CreateObject("Scripting.Dictionary")
- Application.ScreenUpdating = False
- Set sh = ThisWorkbook.Sheets("新数据")
- p = ThisWorkbook.Path & ""
- f = p & "Pn\数据源.xlsx"
- Set wb = Workbooks.Open(f, 0)
- With wb.Sheets(1)
- arr = .UsedRange
- wb.Close False
- End With
- For i = 2 To UBound(arr)
- s = CStr(arr(i, 1))
- d(s) = i
- Next
- With sh
- r = .Cells(Rows.Count, 2).End(3).Row
- For i = 4 To r
- s = CStr(.Cells(i, 2))
- If d.exists(s) Then
- .Cells(i, "AH") = arr(d(s), 4)
- .Cells(i, "AI") = arr(d(s), 5)
- .Cells(i, "AJ") = arr(d(s), 6)
- .Cells(i, "AK") = arr(d(s), 7)
- End If
- st = .Cells(i, "AH") & .Cells(i, "AI") & .Cells(i, "AJ") & .Cells(i, "AK")
- If st <> Empty Then
- Set Rng = .Cells(i, 1).Resize(, 37)
- Rng.Interior.ColorIndex = 15
- End If
- Next
- End With
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|