1、效果如下
2、代码如下
Sub dengdi1()
Dim x, y
x = Range("D2").End(xlDown).Row
For y = 2 To x
Select Case True
Case Cells(y, 4) > 90
Cells(y, 5) = "优秀"
Case Cells(y, 4) <= 90 And Cells(y, 4) > 80
Cells(y, 5) = "良好"
Case Cells(y, 4) <= 80 And Cells(y, 4) >= 60
Cells(y, 5) = "合格"
Case Cells(y, 4) < 60
Cells(y, 5) = "不合格"
End Select
Next
End Sub
3、比较select t case 和 if else两者,select case语句更简洁。