Dim Km As Object, Arr()
Private Sub Worksheet_Activate()
Dim i%
Set Km = CreateObject("Scripting.Dictionary")
Arr = Range("j3:m" & Range("j" & Rows.Count).End(3).Row).Value
For i = 1 To UBound(Arr)
Km(Arr(i, 1)) = i '把代碼和對應的序號裝入字典
Next
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("B3:B126")) Is Nothing Then Exit Sub
Application.EnableEvents = False
' Target.Value = Cells(Rows.Count, "B").End(xlUp).Offset(1, 1)
Target.Offset(0, -1).Value = Date
For i = 1 To 3
Target.Offset(0, i).Value = Arr(Km(Target.Value), i + 1)
Next
' Target.Resize(1, 3).Value = Arr(Km(Target.Value).Items)
Application.EnableEvents = True