Private Sub Worksheet_Change(ByVal Target As Range)
Dim d As Object
Dim x
If Target.Address = "$E$1" Then '如果改变的单元格地址是$E$1
Set d = CreateObject("scripting.dictionary") '创建字典d
For x = 2 To 11
d(Cells(x, 1).Value) = Cells(x, 2) '将Cells(x, 1)单元格的值装入字典d,item是Cells(x, 2)
Next x
Cells(1, 6) = d(Cells(1, 5).Value) 'Cells(1, 6)单元格等于字典key为Cells(1, 5)的item
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim d As Object
Dim x
If Target.Address = "$E$1" Then '如果改变的单元格地址是$E$1
Set d = CreateObject("scripting.dictionary") '创建字典d
For x = 2 To 11
d(Cells(x, 1).Value) = Cells(x, 2) '将Cells(x, 1)单元格的值装入字典d,item是Cells(x, 2)
Next x
Cells(1, 6) = d(Cells(1, 5).Value) 'Cells(1, 6)单元格等于字典key为Cells(1, 5)的item
End If
End Sub