Calculate Grade using VBA Procedure in excel

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

download Grade Excel Sheet here!

calculate gpa and grade

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

To start with, make sure that the VBA 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.

Open developer-toolbar

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

Excel options

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

Developer Toolbar

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.

Developer page visible

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

from menu select insert button then click Module.

insert module

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


Function grad(alpha As Double)
If alpha = 4 Then
grad = "A+"
ElseIf alpha < 4 And alpha >= 3.4 Then
grad = "A"
ElseIf alpha < 3.4 And alpha >= 3.1 Then
grad = "B+"
ElseIf alpha < 3.1 And alpha >= 2.8 Then
grad = "B"
ElseIf alpha < 2.8 And alpha >= 2.4 Then
grad = "B-"
ElseIf alpha < 2.4 And alpha >= 2.1 Then
grad = "C+"
ElseIf alpha < 2.1 And alpha >= 1.8 Then
grad = "C"
ElseIf alpha < 1.8 And alpha >= 1.5 Then
grad = "C-"
ElseIf alpha < 1.5 And alpha >= 1 Then
grad = "D"
End If

End Function

After that write procedure name called Grade then click save button and then close visualbasic editor.

gpa procedure

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

write grade formula

Excel automatic calculates the grade for given marks.

auto calculate grade

copy this formula for other marks

copy grade formula