0% found this document useful (0 votes)
49 views12 pages

Codes

The document contains multiple Visual Basic subroutines that perform various operations related to calculating student grades and GPAs from data in Excel cells and sheets. The subroutines include functions for calculating class GPA from sum of marks and credits, assigning letter grades based on percentage marks, assigning letter grades to multiple students' data, and assigning scores based on gender and performance percentage.

Uploaded by

Vedantam Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views12 pages

Codes

The document contains multiple Visual Basic subroutines that perform various operations related to calculating student grades and GPAs from data in Excel cells and sheets. The subroutines include functions for calculating class GPA from sum of marks and credits, assigning letter grades based on percentage marks, assigning letter grades to multiple students' data, and assigning scores based on gender and performance percentage.

Uploaded by

Vedantam Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Class 14-08-2019

Sub GPA()

Dim Sum, Sump, CGPA, i

For i = 1 To 5

X = Cells(i + 1, 3).Value

Sum = Sum + X

Y = Cells(i + 1, 2).Value

Sump = Sump + (X * Y)

Next

CGPA = Sump / Sum

Cells(9, 2).Value = CGPA

End Sub

Sub lp()

Dim marks, grade

marks = Cells(2, 2).Value

grade = Cells(2, 3).Value

If marks >= 80 Then

grade = "O"

Cells(2, 3) = grade
ElseIf marks >= 75 Then

grade = "A+"

Cells(2, 3) = grade

ElseIf marks >= 70 Then

grade = "A"

Cells(2, 3) = grade

ElseIf marks >= 65 Then

grade = "A-"

Cells(2, 3) = grade

ElseIf marks >= 60 Then

grade = "B+"

Cells(2, 3) = grade

ElseIf marks >= 55 Then

grade = "B"

Cells(2, 3) = grade

ElseIf marks >= 50 Then

grade = "B-"

Cells(2, 3) = grade

ElseIf marks >= 0 Then

grade = "F"

Cells(2, 3) = grade

End If

End Sub

Dim marks, grade, i


For i = 1 To 147

marks = Cells(i + 1, 2).Value

grade = Cells(i + 1, 3).Value

Sheet3.Activate

If marks >= 80 Then

grade = "O"

Cells(i + 1, 3) = grade

ElseIf marks >= 75 Then

grade = "A+"

Cells(i + 1, 3) = grade

ElseIf marks >= 70 Then

grade = "A"

Cells(i + 1, 3) = grade

ElseIf marks >= 65 Then

grade = "A-"

Cells(i + 1, 3) = grade

ElseIf marks >= 60 Then

grade = "B+"

Cells(i + 1, 3) = grade

ElseIf marks >= 55 Then

grade = "B"

Cells(i + 1, 3) = grade

ElseIf marks >= 50 Then

grade = "B-"

Cells(i + 1, 3) = grade

ElseIf marks >= 0 Then


grade = "F"

Cells(i + 1, 3) = grade

End If

Next

End Sub

Dim marks, grade, i, j, n, nr

For n = 1 To 60000

If Cells(n, 2) = "" Then Exit For

Next

nr = n - 1

grade = Cells(i, j + 5).Value

For i = 2 To nr

For j = 2 To 6

marks = Cells(i, j).Value

Sheet4.Activate

If marks >= 80 Then

grade = "O"

Cells(i, j + 5) = grade

ElseIf marks >= 75 Then

grade = "A+"

Cells(i, j + 5) = grade
ElseIf marks >= 70 Then

grade = "A"

Cells(i, j + 5) = grade

ElseIf marks >= 65 Then

grade = "A-"

Cells(i, j + 5) = grade

ElseIf marks >= 60 Then

grade = "B+"

Cells(i, j + 5) = grade

ElseIf marks >= 55 Then

grade = "B"

Cells(i, j + 5) = grade

ElseIf marks >= 50 Then

grade = "B-"

Cells(i, j + 5) = grade

ElseIf marks >= 0 Then

grade = "F"

Cells(i, j + 5) = grade

End If

Next

Next

End Sub
Sub GradePoint_3()

Dim Ws As Worksheet

Set Ws = ThisWorkbook.Sheets("Sheet4")

Dim Val1

Dim i, j

With Ws

For i = 2 To 147

For j = 2 To 6

Val1 = Cells(i, j).Value

If Val1 >= 80 Then

Cells(i, j + 5).Value = "O"

ElseIf Val1 >= 75 Then

Cells(i, j + 5).Value = "A+"

ElseIf Val1 >= 70 Then

Cells(i, j + 5).Value = "A"

ElseIf Val1 >= 65 Then

Cells(i, j + 5).Value = "A-"

ElseIf Val1 >= 60 Then

Cells(i, j + 5).Value = "B+"

ElseIf Val1 >= 55 Then

Cells(i, j + 5).Value = "B"

ElseIf Val1 >= 50 Then

Cells(i, j + 5).Value = "B-"

ElseIf Val1 < 50 Then

Cells(i, j + 5).Value = "F"

End If

Next j
Next i

End With

End Sub

Sub master()

Dim Per, CGPA, score

For i = 3 To 90

For j = 3 To 6

Per = Cells(i, 3).Value

CGPA = Cells(i, 4).Value

score = Cells(i, 6).Value

If Per > 90 Then

Cells(i, 6).Value = "30"

If CGPA > 80 Then

Cells(i, 6).Value = "30"

ElseIf Per > 80 Then

Cells(i, 6).Value = "20"

If CGPA > 70 Then

Cells(i, 6).Value = "20"

ElseIf Per > 70 Then

Cells(i, 6).Value = "15"

If CGPA > 60 Then

Cells(i, 6).Value = "10"


ElseIf Per > 60 Then

Cells(i, 6).Value = "10"

If CGPA > 50 Then

Cells(i, 6).Value = "5"

ElseIf Per > 50 Then

Cells(i, 6).Value = "5"

ElseIf Per < 50 Then

Cells(i, 6).Value = "0"

If CGPA < 50 Then

Cells(i, 6).Value = "0"

End If

Next i

Next j

End With

End Sub

End Sub

Sub Quiz()

Dim Per, CGPA, score

Per = Cells(i, 3).Value

CGPA = Cells(i, 4).Value


score = Cells(i, 6).Value

For i = 3 To 90

If Per = "" Then

ElseIf CGPA > 80 Then

Cells(i, 6).Value = "30"

If Per = "" Then

ElseIf CGPA > 70 Then

Cells(i, 6).Value = "20"

If Per = "" Then

ElseIf CGPA > 60 Then

Cells(i, 6).Value = "10"

If Per = "" Then

ElseIf CGPA > 50 Then

Cells(i, 6).Value = "5"

If Per = "" Then

ElseIf CGPA < 50 Then

Cells(i, 6).Value = "0"

If Per > "90" Then

ElseIf CGPA = "" Then

Cells(i, 6).Value = "30"

If Per > "80" Then


ElseIf CGPA = "" Then

Cells(i, 6).Value = "20"

If Per > "70" Then

ElseIf CGPA = "" Then

Cells(i, 6).Value = "15"

If Per > "60" Then

ElseIf CGPA = "" Then

Cells(i, 6).Value = "10"

If Per > "50" Then

ElseIf CGPA = "" Then

Cells(i, 6).Value = "5"

If Per < "50" Then

ElseIf CGPA = "" Then

Cells(i, 6).Value = "0"

End If

Next i

End Sub
Sub class1()

Dim Gender, score

Sheet1.Activate

For i = 2 To 21

Gender = Cells(i, 2)

If Gender = "m" Then

score = 20

ElseIf Gender = "f" Then

score = 40

End If

Cells(i, 3).Value = score

Next i

End Sub

Sub class1()

Sheet1.Activate

Dim Gender As String

Dim i As Integer

For i = 2 To 21

Gender = Cells(i, 2)

Select Case Gender


Case "m"

Cells(i, 3) = 20

Case "f"

Cells(i, 3) = 40

Case Else

MsgBox "Problem in Gender Data Entry"

End Select

Next

End Sub

You might also like