|
用下面的代码实现查找引用,并限制重复录入,单个录入的时候正常,但我想批量粘贴时也能实现查找引用功能?如何写代码?
现在的代码单个输入的时候能实现查找引用,但同时粘贴多个单元格的时候就不能用了!新手恳请帮忙!
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1
If Target.Value <> "" And Application.CountIf(Columns(1), Target.Value) > 1 Then
MsgBox "请不要重复录入"
Application.Undo
End If
Set c = Sheets("物料表").Range("a2:a65536").Find(Target.Value, lookat:=xlWhole)
If Not c Is Nothing Then
Target.Offset(0, 1) = c.Offset(0, 1)
Target.Offset(0, 2) = c.Offset(0, 2)
Target.Offset(0, 4) = c.Offset(0, 5)
End If
End If
End Sub |
|