+ Reply to Thread
Results 1 to 2 of 2

Vba/excel

  1. #1
    Registered User
    Join Date
    01-25-2005
    Posts
    4

    Vba/excel

    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

  2. #2
    Forum Contributor
    Join Date
    12-04-2003
    Posts
    360
    Attack your problem from a different angle.

    You have all the information you require.

    Set up a new worksheet with a results slip with empty cell available for all the data gathered in the sub.

    Insert the values into the template rather than displaying in dialog box.
    i.e results!A1 = StrStudentName

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1