|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Option Explicit
Sub TEST2()
Dim ar, br, i&, j&, dic As Object
Application.ScreenUpdating = False
Set dic = CreateObject("Scripting.Dictionary")
ar = Worksheets(1).UsedRange.Value
For i = 2 To UBound(ar)
If Len(ar(i, 5)) Then
dic(ar(i, 5)) = Array(ar(i, 5), ar(i, 6))
For j = 5 To 6
ar(i, j) = Empty
Next j
End If
Next i
For i = 2 To UBound(ar)
If ar(i, 1) = "离职" Then
If dic.Count > 0 Then
For j = 1 To 3
ar(i, j) = Empty
br = dic.items()(0)
ar(i, 2) = br(0): ar(i, 3) = br(1)
Next j
Else
Exit For
End If
End If
Next i
With Worksheets(2)
.Cells.Clear
.[A1].Resize(UBound(ar), UBound(ar, 2)) = ar
.Activate
End With
Application.ScreenUpdating = True
Beep
End Sub
|
|