算绩点,90--100分区间的给4.5 然后再用4.5乘以学分
我没能写对Private Sub CommandButton1_Click()
For i = Cells(6, 2) To Cells(7, 2)
Cells(i, Cells(8, 2)) = 0
Next iFor i = Cells(6, 2) To Cells(7, 2)
  For j = Cells(9, 2) To Cells(10, 2)
  If IsNumeric(Cells(i, j)) = True Then If Cells(i, j) >= 90& & Cells(i, j) <= 100 Then Cells(i, Cells(8, 2)) = Cells(i, Cells(8, 2)) + Cells(Cells(11, 2), j).Value = 4.5
  If IsNumeric(Cells(i, j)) = True Then If Cells(i, j) >= 80& & Cells(i, j) < 90 Then Cells(i, Cells(8, 2)) = Cells(i, Cells(8, 2)) + Cells(Cells(11, 2), j).Value = 3.5
  If IsNumeric(Cells(i, j)) = True Then If Cells(i, j) >= 70& & Cells(i, j) < 80 Then Cells(i, Cells(8, 2)) = Cells(i, Cells(8, 2)) + Cells(Cells(11, 2), j).Value = 2.5
  If IsNumeric(Cells(i, j)) = True Then If Cells(i, j) >= 60& & Cells(i, j) < 70 Then Cells(i, Cells(8, 2)) = Cells(i, Cells(8, 2)) + Cells(Cells(11, 2), j).Value = 1.5
  If IsNumeric(Cells(i, j)) = True Then If Cells(i, j) >= 0& & Cells(i, j) < 60 Then Cells(i, Cells(8, 2)) = Cells(i, Cells(8, 2)) + Cells(Cells(11, 2), j).Value = 0  If IsNumeric(Cells(i, j)) = False Then If Cells(i, j) = "不及格" Then Cells(i, Cells(8, 2)) = Cells(i, Cells(8, 2)) + Cells(Cells(11, 2), j).Value = 0
  If IsNumeric(Cells(i, j)) = False Then If Cells(i, j) = "及格" Then Cells(i, Cells(8, 2)) = Cells(i, Cells(8, 2)) + Cells(Cells(11, 2), j).Value = 1.5
  If IsNumeric(Cells(i, j)) = False Then If Cells(i, j) = "中" Then Cells(i, Cells(8, 2)) = Cells(i, Cells(8, 2)) + Cells(Cells(11, 2), j).Value = 2.5
  If IsNumeric(Cells(i, j)) = False Then If Cells(i, j) = "良" Then Cells(i, Cells(8, 2)) = Cells(i, Cells(8, 2)) + Cells(Cells(11, 2), j).Value = 3.5
  If IsNumeric(Cells(i, j)) = False Then If Cells(i, j) = "优" Then Cells(i, Cells(8, 2)) = Cells(i, Cells(8, 2)) + Cells(Cells(11, 2), j).Value = 4.5
  Next j
Next i
End Sub

解决方案 »

  1.   

    在Excel中开始记录宏,手动完成所需功能,结束记录宏,按Alt+F11键,查看刚才记录的宏对应的VBA代码。
      

  2.   

    请参考:
    sub test
       dim Rngs as range,Rng as range
      set rngs=sheet1.range("a3:h33")'''
      for each rng in rngs
         select case val(rng.value)
         case 90 to 100
             rng.offset(0,1).value=4.5*学分''''在后面一列对应位置
         case else
            select case rng.value
            case "合格"
            case "不及格"
            case "优秀"
            end select      end select
      next
    end sub