|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
原帖由 puresway 于 2011-3-2 22:28 发表
赵老师,能不能再麻烦您在备注(K列)后面(L列)加上“目前达到职级”啊,谢谢
Sub Macro1()
Dim d As Object, arr, brr, crr(), i&, r&
Set d = CreateObject("scripting.dictionary")
arr = Sheets("考核标准").Range("A1").CurrentRegion
For i = 3 To UBound(arr)
d(arr(i, 1)) = i
Next
brr = Range("C3:E" & Range("C65536").End(xlUp).Row)
ReDim crr(1 To UBound(brr), 1 To 7)
For i = 1 To UBound(brr)
If d.Exists(brr(i, 1)) Then
r = d(brr(i, 1))
If brr(i, 2) >= arr(r, 2) Then
If brr(i, 2) >= Val(arr(r - 1, 3)) And brr(i, 3) >= Val(arr(r - 1, 4)) Then
If r >= 5 Then
crr(i, 6) = "晋升两级"
crr(i, 7) = arr(r - 2, 1)
Else
crr(i, 6) = "维持" & Left(brr(i, 1), 2)
crr(i, 7) = brr(i, 1)
End If
ElseIf brr(i, 2) >= Val(arr(r, 3)) And brr(i, 3) >= Val(arr(r, 4)) Then
If r >= 4 Then
crr(i, 6) = "晋升一级"
crr(i, 4) = brr(i, 2) - arr(r - 1, 3)
crr(i, 5) = brr(i, 3) - arr(r - 1, 4)
crr(i, 7) = arr(r - 1, 1)
Else
crr(i, 6) = "维持" & Left(arr(i, 1), 2)
End If
Else
crr(i, 6) = "维持待晋"
crr(i, 2) = brr(i, 2) - arr(r, 3)
crr(i, 3) = brr(i, 3) - arr(r, 4)
crr(i, 7) = brr(i, 1)
End If
Else
crr(i, 1) = brr(i, 2) - arr(r, 2)
If r < 10 Then
If brr(i, 2) <= arr(r + 1, 2) Then
crr(i, 6) = "待维持:目前降两级"
crr(i, 7) = arr(r + 2, 1)
Else
crr(i, 6) = "待维持:目前降一级"
crr(i, 7) = arr(r + 1, 1)
End If
ElseIf r = 10 Then
If brr(i, 2) <= arr(r + 1, 2) Then
crr(i, 6) = "待维持:目前降一级"
crr(i, 7) = arr(r + 1, 1)
End If
Else
crr(i, 6) = "待维持:增加一个考核期后离职"
crr(i, 7) = brr(i, 1)
End If
End If
End If
Next
Range("f3").Resize(i - 1, 7) = crr
End Sub |
|