|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
原帖由 lisan 于 2011-1-4 20:20 发表
如果是本人,也希望按这种格式 孙艳 - 孙艳(本人)。
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(0, 0) <> "A1" Then Exit Sub
If Target = "" Then Exit Sub
Dim wb As Workbook, c As Range, s$
s = Target
On Error Resume Next
Application.ScreenUpdating = False
Set wb = Workbooks("人员信息.xls")
If wb Is Nothing Then Set wb = Workbooks.Open(ThisWorkbook.Path & "\人员信息.xls")
wb.Sheets("Sheet1").[a65536].End(xlUp).Offset(1) = Target
With wb.Sheets("Agent Info")
Set c = .UsedRange.Offset(, 7).Find(s, , , xlWhole)
If Not c Is Nothing Then
If c.Column = 8 Then
wb.Sheets("Sheet1").[a65536].End(xlUp).Offset(, 1) = c.Offset(, -3) & "-" & c.Offset(, -3) & "(本人)"
Else
wb.Sheets("Sheet1").[a65536].End(xlUp).Offset(, 1) = c.Offset(, -1) & "-" & .Cells(c.Row, 5) & "(" & Replace(.Cells(1, c.Column - 1), "姓名", "") & ")"
End If
Else
wb.Sheets("Sheet1").[a65536].End(xlUp).Offset(, 1) = "不存在"
End If
End With
Me.Activate
Application.ScreenUpdating = True
End Sub |
|