|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Private Sub Worksheet_Change(ByVal Target As Range)
Set d = CreateObject("scripting.dictionary")
Set Rng = Application.Intersect(Columns(3), Target)
If Rng Is Nothing Then Exit Sub
Application.ScreenUpdating = False
Application.EnableEvents = False
arr = Sheets("人员信息").UsedRange
For j = 2 To UBound(arr)
d(arr(j, 3)) = j
Next j
For j = 2 To UBound(arr, 2)
d(arr(1, j)) = j
Next j
For Each rn In Rng
If Len(rn) = 0 Then
Cells(rn.Row, 4).Resize(1, 3).Value = ""
Cells(rn.Row, 2) = ""
Cells(rn.Row, 1) = ""
Else
If Not d.exists(rn.Value) Then
Cells(rn.Row, 4).Resize(1, 5).Value = ""
Cells(rn.Row, 1) = ""
Else
r = d(rn.Value)
Cells(rn.Row, 1) = WorksheetFunction.CountA([a1].Resize(rn.Row - 1)) - 1
For i = 2 To Cells(1, Columns.Count).End(xlToLeft).Column
Cells(rn.Row, i) = "'" & arr(r, d(Cells(1, i).Value))
Next i
End If
End If
Next
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub
|
|