1、效果如下图:
2、代码如下:
Option Explicit
Sub dengdi()
Dim x, y
x = Range("D2").End(xlDown).Row
For y = 2 To x
If Cells(y, 4) > 90 Then
Cells(y, 5) = "优秀"
ElseIf Cells(y, 4) <= 90 And Cells(y, 4) > 80 Then
Cells(y, 5) = "良好"
ElseIf Cells(y, 4) <= 80 And Cells(y, 4) >= 60 Then
Cells(y, 5) = "合格"
ElseIf Cells(y, 4) < 60 Then
Cells(y, 5) = "不合格"
End If
Next
End Sub