|
好吧,把下面的代码替换掉原来的代码就可以了Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
Dim X
X = Sheets("员工库").[A65536].End(xlUp).Row '得到员工库的最后一行数据的行号
If Target.Count = 1 Then '如果仅选定一个单元格
Application.EnableEvents = False '停止事件发生
For I = 2 To X '循环查找
With Sheets("员工库").Cells(I, 1)
If .Value = Target.Value Then
'Target.Offset(0, 1).Value = .Offset(0, 1).Value
Target.Value = .Offset(0, 1).Value
'If Target.Offset(0, -1).Value = "" Then
'Target.Offset(0, -1).Value = Application.WorksheetFunction.Max(Range("A:A")) + 1
'End If
End If
End With
Next I
Application.EnableEvents = True
End If
End Sub |
|