Hi, the macro I'm writing is supposed to generate a grade depending on the marks that have already been typed in. For example if a mark falls between 80 and 100, the grade given would be N [which stands for High distinction but that's irrelevant]. I have written the following code:
Sub markToGrade()
Dim mark As String
Dim grade As String
For i = 1 To 19
mark = Cells(i, 1).Value
grade = Cells(i, 2).Value
Select Case mark
Case 1 To 49
Cells(i, 2) = "N"
Case 50 To 59
Cells(i, 2) = "P"
Case 60 To 69
Cells(i, 2) = "C"
Case 70 To 79
Cells(i, 2) = "D"
Case 80 To 99
Cells(i, 2) = "HD"
Case Else
Cells(i, 2) = "**"
End Select
Next i
End Sub
--
The problem here is, the macro treats marks that fall in the range of 5 to 8 as "case else" and inputs HD if the mark is 9. What's happening? I'm defining mark as string because students with undetermined grades have ** as marks and integer doesn't recognize symbols. On a side note, is it possible to code i such that i = activecell?
Many thanks in advance!
Bookmarks