原帖由 puresway 于 2011-3-3 09:59 发表
赵老师,小弟现在还有个问题,资深二级的维持和晋升好像有点问题,可能还是因为小弟的表述给老师造成误解了,资深二级应该可以晋升一级的,但不能晋升两级,因为到顶了,另外如果维持但不能晋的话,就写“维持待晋 ...
先测试第一个要求:
Sub Macro1()
Dim d As Object, arr, brr, crr(), i&, r&
Set d = CreateObject("scripting.dictionary")
arr = Sheets("考核标准").Range("A1").CurrentRegion
arr(2, 3) = 10000: arr(2, 4) = 10000: arr(3, 3) = 10000: arr(3, 4) = 10000
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) = "晋升一级"
If r > 4 Then crr(i, 4) = brr(i, 2) - arr(r - 1, 3)
If r > 4 Then crr(i, 5) = brr(i, 3) - arr(r - 1, 4)
crr(i, 7) = arr(r - 1, 1)
Else
crr(i, 6) = "维持" & Left(brr(i, 1), 2)
crr(i, 7) = brr(i, 1)
End If
Else
crr(i, 6) = "维持待晋"
If r > 3 Then crr(i, 2) = brr(i, 2) - arr(r, 3)
If r > 3 Then 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, 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 |