Search

Translate Page in your Language

GPA Calculation

GPA Calculation

How to Calculate GPA using VBA Procedure in excel


We want to calculate GPA with students exam numbers and We have an excel sheet.


By opening the Microsoft VisualBasic Applications window you can access the VisualBasic (VBA) environment in Excel 2007-2013

To start with, make certain that the DEVELOPER tab is visible in the toolbar in Excel 2007.
The DEVELOPER tab is the toolbar that has the buttons to open the VisualBasic (VBA) editor.
To show the Developer tab, click on FILE in the menu and select Options starting from the drop menu.




At the point when the Excel Options window shows up, click on the Customize Ribbon alternative on the left.


Click on the VBA Developer checkbox under the list of MainTabs on the right. Then click on the OK button.


Select the VBA DEVELOPER tab from the toolbar at the top of the screen. Then click on the Visual Basic option in the Code group.


Presently the Microsoft VisualBasic VBA for Applications editor should appear and you insert your VisualBasic VBA code.

from menu select insert then click Module.


The Visual Basic for Applications editor should to show up then insert function GPA.



Function gpa(res As Double)
If res <= 100 And res > 84 Then
gpa = 4
ElseIf res <= 84 And res > 83 Then
gpa = 3.9
ElseIf res <= 83 And res > 82 Then
gpa = 3.75
ElseIf res <= 82 And res > 81 Then
gpa = 3.6
ElseIf res <= 81 And res > 80 Then
gpa = 3.5
ElseIf res <= 80 And res > 79 Then
gpa = 3.4
ElseIf res <= 79 And res > 78 Then
gpa = 3.3
ElseIf res <= 78 And res > 76 Then
gpa = 3.2
ElseIf res <= 76 And res > 74 Then
gpa = 3.1
ElseIf res <= 74 And res > 73 Then
gpa = 3
ElseIf res <= 73 And res > 71 Then
gpa = 2.9
ElseIf res <= 71 And res > 69 Then
gpa = 2.8
ElseIf res <= 69 And res > 68 Then
gpa = 2.7
ElseIf res <= 68 And res > 67 Then
gpa = 2.6
ElseIf res <= 67 And res > 65 Then
gpa = 2.5
ElseIf res <= 65 And res > 64 Then
gpa = 2.4
ElseIf res <= 64 And res > 63 Then
gpa = 2.3
ElseIf res <= 63 And res > 61 Then
gpa = 2.2
ElseIf res <= 61 And res > 60 Then
gpa = 2.1
ElseIf res <= 60 And res > 59 Then
gpa = 2
ElseIf res <= 59 And res > 58 Then
gpa = 1.9
ElseIf res <= 58 And res > 57 Then
gpa = 1.8
ElseIf res <= 57 And res > 56 Then
gpa = 1.7
ElseIf res <= 56 And res > 55 Then
gpa = 1.6
ElseIf res <= 55 And res > 54 Then
gpa = 1.5
ElseIf res <= 54 And res > 53 Then
gpa = 1.4
ElseIf res <= 53 And res > 52 Then
gpa = 1.3
ElseIf res <= 52 And res > 51 Then
gpa = 1.2
ElseIf res <= 51 And res > 50 Then
gpa = 1.1
ElseIf res <= 50 And res > 49 Then
gpa = 1
Else
gpa = 0
End If
End Function

After that write procedure name called gpa then click save button and then close visual basic editor.


Now in cell O5 write formula for cell N5 to calculate GPA =gpa(N5),


Excel automatic calculates the gpa for given marks.


copy this formula for other marks



No comments:

Post a Comment