原帖由 puresway 于 2011-3-2 13:09 发表
谢谢赵老师,前面的几列就是要写入他的达成指标与他职级对应最近的考核标准的差额,如果总指标没有达到维持,就在维持差额列写入距离维持的差额,达到了维持,就看他是否满足晋升一级所需的两个指标,如果不满足,就 ...
理解有偏差,修改如下:
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 6)
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) = "晋升两级"
Else
crr(i, 6) = "维持" & Left(brr(i, 1), 2)
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)
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)
End If
Else
crr(i, 6) = "待维持"
crr(i, 1) = brr(i, 2) - arr(r, 2)
End If
End If
Next
Range("f3").Resize(i - 1, 6) = crr
End Sub |