Sub Normal()
Dim arr As Variant
Dim i As Integer
arr = Range("C3:I252").Value2
Application.ScreenUpdating = False
i = 1
Do While Len(arr(i, 2)) > 10
Select Case arr(i, 4)
Case is > 3
arr(i, 5) = "差"
Case is = 3
arr(i, 5) = "中"
Case is > 0
arr(i, 5) = "好"
End Select
If Instr(8, arr(i + 1, 2), "C", 0) > 0 Then
Select Case arr(i + 1, 5)
Case Is = "中", "差"
arr(i + 1, 7) = "已处理"
End Select
ElseIf Instr(8, arr(i + 1, 2), "D", 0) > 0 Then
Select Case arr(i + 1, 5)
Case Is = "中", "差"
arr(i + 1, 7) = "待处理"
End Select
End If
If Instr(14, arr(i + 2, 2), "-1", 0) > 0 Then
If Len(arr(i + 3, 2)) <14 Then
Select Case Len(arr(i + 4, 2))
Case is > 14
arr(i + 3, 2) = Replace(arr(i + 2, 2), "-1", "-2")
Case is < 14
arr(i + 3, 2) = Replace(arr(i + 2, 2), "-1", "-2")
arr(i + 4, 2) = Replace(arr(i + 2, 2), "-1", "-3")
End Select
End If
ElseIf Instr(14, arr(i + 2, 2), "-2", 0) > 0 Then Select Case Len(arr(i + 3, 2))
Case is < 14
arr( i + 3, 2) = Replace(arr(i + 2, 2), "-2", "-3")
End Select
End If
If Instr(14, arr(i + 3, 2), "-1", 0) > 0 And _
Len(arr(i + 4, 2)) < 14 Then
arr( i + 4, 2) = Replace(arr(i + 3, 2), "-1", -2")
ElseIf Instr(14, arr(i + 3, 2), "-2", 0) > 0 _
And Len(arr(i + 4, 2)) < 14 Then
arr( i + 4, 2) = Replace(arr(i + 3, 2), "-2", "-3")
End If
i = i + 5
Loop
Application.ScreenUpdating = True
Range("C3:I252").Value2 = arr
End Sub
运行代码,提示下标越界,Do While那一行被标黄。看本地窗口,250组元素和i,值那一列最下面显示251,居然还能修改,我把它改成250,运行正常了。但是关闭重新运行,还是越界,还是251
|