|
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 4 And Target.Row > 2 Then
Set d = CreateObject("Scripting.Dictionary")
With Sheets("产品资料")
r = .Cells(Rows.Count, 1).End(3).Row
arr = .Range("A3:E" & r)
For i = 1 To UBound(arr)
d(arr(i, 1)) = i
Next
For Each cel In Target
If cel.Value = "" Then
cel.Offset(, 1) = ""
cel.Offset(, 2) = ""
cel.Offset(, 3) = ""
cel.Offset(, 4) = ""
cel.Offset(, 5) = ""
Else
If d.exists(cel.Value) Then
cel.Offset(, 1) = arr(d(cel.Value), 2)
cel.Offset(, 2) = arr(d(cel.Value), 3)
cel.Offset(, 3) = arr(d(cel.Value), 4)
cel.Offset(, 4) = arr(d(cel.Value), 5)
End If
End If
Next
End With
End If
End Sub
各位大神,能否帮我把这段代码每行注释一下,能让小白看得差不多能修改到我自己的表里
|
|