I've made a subroutine on (Excel/VBA), to be run from the macro window which will ask for the name of the student and find the result for that student, displaying the results for each assessment, and the overall grade . But i need to print these results and grades to produce result slip for each student displaying in the message box.
This is my code
Public Sub DisplayStudentResults()
Dim StrStudentName As String
Dim lngTestOne As Long
Dim lngTestTwo As Long
Dim lngTestThree As Long
Dim lngTestFour As Long
Dim lngTestFive As Long
Dim lngProject As Long
Dim StrOverallGrade As String
Dim lngResponse As Long
lngResponse = vbYes
Do Until lngResponse = vbNo
lngTestOne = 0
lngTestTwo = 0
lngTestThree = 0
lngTestFour = 0
lngTestFive = 0
lngProject = 0
StrStudentName = InputBox("Enter Student Name to be display")
Range("B6").Select
Do Until ActiveCell.Value = ""
If ActiveCell.Value = StrStudentName Then
ActiveCell.Offset(0, 1).Range("A1").Select
lngTestOne = lngTestOne + ActiveCell.Value
ActiveCell.Offset(0, 1).Range("A1").Select
lngTestTwo = lngTestTwo + ActiveCell.Value
ActiveCell.Offset(0, 1).Range("A1").Select
lngTestThree = lngTestThree + ActiveCell.Value
ActiveCell.Offset(0, 1).Range("A1").Select
lngTestFour = lngTestFour + ActiveCell.Value
ActiveCell.Offset(0, 1).Range("A1").Select
lngTestFive = lngTestFive + ActiveCell.Value
ActiveCell.Offset(0, 1).Range("A1").Select
lngProject = lngProject + ActiveCell.Value
ActiveCell.Offset(0, 2).Range("A1").Select
StrOverallGrade = StrOverallGrade + ActiveCell.Value
ActiveCell.Offset(0, -8).Range("A1").Select
End If
ActiveCell.Offset(1, 0).Range("A1").Select
Loop
MsgBox ("Student Name = " & StrStudentName & vbCrLf & _
"Test1= " & lngTestOne & vbCrLf & _
"Test2= " & lngTestTwo & vbCrLf & _
"Test3= " & lngTestThree & vbCrLf & _
"Test4= " & lngTestFour & vbCrLf & _
"Test5 =" & lngTestFive & vbCrLf & _
"Project= " & lngProject & vbCrLf & _
"OverallGrade= " & (StrOverallGrade))
End If
lngResponse = MsgBox("Do you want another Search? Press Yes or No.", vbYesNo)
Loop
End Sub
Many thanks
Bookmarks