2,462
社区成员
发帖
与我相关
我的任务
分享
Sub x()
Dim dict
Set dict = CreateObject("Scripting.Dictionary")
For i = 2 To Sheet2.UsedRange.Rows.Count
dict.Add Sheet2.Cells(i, 1).Value, Sheet2.Cells(i, 2).Value
Next
For Each k In dict
Debug.Print k, dict.Item(k)
Next
For i = 2 To Sheet1.UsedRange.Rows.Count
If dict.Exists(Sheet1.Cells(i, 1).Value) Then
Sheet1.Cells(i, 2) = dict.Item(Sheet1.Cells(i, 1).Value)
Sheet1.Cells(i, 1).Interior.ColorIndex = 27
End If
Next
End Sub