设置主页 | 收藏本站 Excel学习网-公益型的EXCEL在线学习网站,助您轻松办公!

如何根据分数为员工评定星级

2021年10月23日 14:50 发布来源:Excel学习网

   如果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 Select End 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 If End Sub

原创文章如转载请注明:转载自Excel学习网 [ http://www.excelcn.com/]
需要保留本文链接地址:http://www.excelcn.com/xuexixinde/14035.html
分享到:
网站地图 | XML地图 | 免责声明 | 关于我们 | Excel学习网:优秀的EXCEL在线学习和资源分享网站。
版权所有: CopyRight © 2013-2018 www.excelcn.com All Rights Reserved.
豫ICP备12002644号