首页  >  Word

根据分数为职工评定星级

Word 2024-04-15 12:00:14 33

本文为随书问题参考答案

如果H2单元格中保存的成绩是0到150之间的整数,用Select Case解决的代码可以写为:

Sub 用Slect语句评定星级()
Select Case Cells(2, "H").Value
Case Is < 85 Cells(2, "I").Value = "不评级" Case Is < 100 Cells(2, "I").Value = "一星级" Case Is < 115 Cells(2, "I").Value = "二星级" Case Is < 130 Cells(2, "I").Value = "三星级" Case Is < 150 Cells(2, "I").Value = "四星级" Case Else Cells(2, "I").Value = "五星级" End SelectEnd Sub

用If语句解决的代码可以写为:

Sub 用If语句评定星级()
Dim Cj As Integer
Cj = Cells(2, "H").Value
If Cj < 85 Then Cells(2, "I").Value = "不评级" ElseIf Cj < 100 Then Cells(2, "I").Value = "一星级" ElseIf Cj < 115 Then Cells(2, "I").Value = "二星级" ElseIf Cj < 130 Then Cells(2, "I").Value = "三星级" ElseIf Cj < 150 Then Cells(2, "I").Value = "四星级" ElseIf Cj = 150 Then Cells(2, "I").Value = "五星级" End IfEnd Sub

评定等级
版权声明

本文来自投稿,不代表本站立场,转载请注明出处。

分享:

扫一扫在手机阅读、分享本文