none
run time error 13 type mismatch RRS feed

  • Question

  • Private Sub CommandButton1_Click()
    
    
    Dim mark As Integer
    Dim grade, strComment As String
    
          
    
    
    If IsNumeric(Sheets("roster2").Range("C2:C31").Value) = True _
    And Sheets("roster2").Range("C2:C31").Value <> "" Then
        If Sheets("roster2").Range("C2:C31").Value < 0 Or _
            Sheets("roster2").Range("C2:C31").Value > 100 Then
            
            MsgBox ("Wrong Data")
            Exit Sub
        Else
            mark = Sheets("roster2").Range("C2:C31").Value
        End If
    Else
        MsgBox ("Wrong Data")
        Exit Sub
    End If
    
    'Depending on the value will give a letter grade and pass/fail
    
    If mark <= 100 And mark >= 90 Then
        grade = "A"
        strComment = "pass"
    ElseIf mark < 90 And mark >= 80 Then
        grade = "B"
        strComment = "pass"
    ElseIf mark < 80 And mark >= 75 Then
        grade = "C"
        strComment = "pass"
    ElseIf mark < 75 And mark >= 70 Then
        grade = "C"
        strComment = "fail"
    ElseIf mark < 70 And mark >= 60 Then
        grade = "D"
        strComment = "fail"
    ElseIf mark < 60 And mark >= 0 Then
        grade = "F"
        strComment = "fail"
    
    End If
    
    ' which cell the pass/fail and letter grade will appear on
    
    Sheets("roster2").Range("B2:B31").Value = grade
    Sheets("roster2").Range("D2:D31").Value = strComment
    
    
    End Sub
    

    Thursday, March 14, 2013 5:54 PM

Answers