Hello again,
i want to create a macro that will compute the rating. when I run the macro and click the button,
I receive Run-time Error '13': Type Mismatch when I try to run the code. Debug highlights the 'IF' statements, but I can't figure out where the mistake is. Any help would be appreciated. Thanks
Private Sub CommandButton1_Click()
Dim score As Integer, result As String
rating = Range("E6:E20").Value
If rating > "98.5%" Then
result = "Exceeds"
ElseIf rating = "96% > 98.49%" Then
result = "Meets"
Else
result = "Needs"
End If
Range("F6:F20").Value = result
End Sub
[TABLE="width: 484"]
<tbody>[TR]
[TD]SCORE[/TD]
[TD]RATING[/TD]
[TD][/TD]
[TD]RANGE[/TD]
[TD]RATING[/TD]
[/TR]
[TR]
[TD]95.00%[/TD]
[TD] must be "Needs"[/TD]
[TD][/TD]
[TD]98.50% - 100%[/TD]
[TD]Exceeds[/TD]
[/TR]
[TR]
[TD]98.01%[/TD]
[TD] must be "Meets"[/TD]
[TD][/TD]
[TD]96% - 98.49%[/TD]
[TD]Meets[/TD]
[/TR]
[TR]
[TD]99.00%[/TD]
[TD] must be "Exceeds"[/TD]
[TD][/TD]
[TD]below 96%[/TD]
[TD]Needs[/TD]
[/TR]
[TR]
[TD]99.50%[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]97.66%[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]94.50%[/TD]
[TD][/TD]
[TD][/TD]
[TD="colspan: 2"][/TD]
[/TR]
[TR]
[TD]95.78%[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]98.56%[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]97.69%[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]95.45%[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]98.00%[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]99.97%[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]98.99%[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]97.97%[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]98.95%[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
i want to create a macro that will compute the rating. when I run the macro and click the button,
I receive Run-time Error '13': Type Mismatch when I try to run the code. Debug highlights the 'IF' statements, but I can't figure out where the mistake is. Any help would be appreciated. Thanks
Private Sub CommandButton1_Click()
Dim score As Integer, result As String
rating = Range("E6:E20").Value
If rating > "98.5%" Then
result = "Exceeds"
ElseIf rating = "96% > 98.49%" Then
result = "Meets"
Else
result = "Needs"
End If
Range("F6:F20").Value = result
End Sub
[TABLE="width: 484"]
<tbody>[TR]
[TD]SCORE[/TD]
[TD]RATING[/TD]
[TD][/TD]
[TD]RANGE[/TD]
[TD]RATING[/TD]
[/TR]
[TR]
[TD]95.00%[/TD]
[TD] must be "Needs"[/TD]
[TD][/TD]
[TD]98.50% - 100%[/TD]
[TD]Exceeds[/TD]
[/TR]
[TR]
[TD]98.01%[/TD]
[TD] must be "Meets"[/TD]
[TD][/TD]
[TD]96% - 98.49%[/TD]
[TD]Meets[/TD]
[/TR]
[TR]
[TD]99.00%[/TD]
[TD] must be "Exceeds"[/TD]
[TD][/TD]
[TD]below 96%[/TD]
[TD]Needs[/TD]
[/TR]
[TR]
[TD]99.50%[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]97.66%[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]94.50%[/TD]
[TD][/TD]
[TD][/TD]
[TD="colspan: 2"][/TD]
[/TR]
[TR]
[TD]95.78%[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]98.56%[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]97.69%[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]95.45%[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]98.00%[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]99.97%[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]98.99%[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]97.97%[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]98.95%[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]