Hello all, I'm very new to VBA...
I understand that generally a type mismatch means you have a variable defined wrong. But I can't figure out what it is!
There's an Excel sheet with a grades. Test 1, Test 2, Test 3, etc.
I'm trying to calculate the final grade with specific curves with their ID.
I just need help with the Error 13 Type MisMatch. I want to figure everything else out on my own.
In the ranges they are all numbers between 0 and 100. The FinalAverage has decimal points. But that's it. It worked until I did the Else statement.
Can anyone please help?
Sub GetFinalGrade()
'Declaration of Variables
Dim strIDQuestion As String
Dim sngCurve1 As Single
Dim sngElseCurve As Single
Dim sngFinalGrade As Single
Dim sngTest1 As Single
Dim sngTest2 As Single
Dim sngTest3 As Single
Dim sngFinalAverage As Single
'Assign variables to their values
sngCurve1 = 0.05
sngElseCurve = 0.02
sngTest1 = Sheets("Fall 2016 Grades").Range("D2:D13")
sngTest2 = Sheets("Fall 2016 Grades").Range("E2:E13")
sngTest3 = Sheets("Fall 2016 Grades").Range("F2:F13")
sngFinalAverage = Sheets("Fall 2016 Grades").Range("G2:G13")
'Asks what their ID is
strIDQuestion = InputBox("What is your student ID?", "Your Grade For You")
'Elseifs to decide what final grade is
If sngTest3 > sngTest1 And sngTest2 Then
sngFinalGrade = (sngFinalAverage * sngCurve1)
Else
sngFinalGrade = (sngFinalAverage * sngElseCurve)
End If
End Sub
I understand that generally a type mismatch means you have a variable defined wrong. But I can't figure out what it is!
There's an Excel sheet with a grades. Test 1, Test 2, Test 3, etc.
I'm trying to calculate the final grade with specific curves with their ID.
I just need help with the Error 13 Type MisMatch. I want to figure everything else out on my own.
In the ranges they are all numbers between 0 and 100. The FinalAverage has decimal points. But that's it. It worked until I did the Else statement.
Can anyone please help?
Sub GetFinalGrade()
'Declaration of Variables
Dim strIDQuestion As String
Dim sngCurve1 As Single
Dim sngElseCurve As Single
Dim sngFinalGrade As Single
Dim sngTest1 As Single
Dim sngTest2 As Single
Dim sngTest3 As Single
Dim sngFinalAverage As Single
'Assign variables to their values
sngCurve1 = 0.05
sngElseCurve = 0.02
sngTest1 = Sheets("Fall 2016 Grades").Range("D2:D13")
sngTest2 = Sheets("Fall 2016 Grades").Range("E2:E13")
sngTest3 = Sheets("Fall 2016 Grades").Range("F2:F13")
sngFinalAverage = Sheets("Fall 2016 Grades").Range("G2:G13")
'Asks what their ID is
strIDQuestion = InputBox("What is your student ID?", "Your Grade For You")
'Elseifs to decide what final grade is
If sngTest3 > sngTest1 And sngTest2 Then
sngFinalGrade = (sngFinalAverage * sngCurve1)
Else
sngFinalGrade = (sngFinalAverage * sngElseCurve)
End If
End Sub