Suggestions for Simple VBA

n107jkx

Board Regular
Joined
Dec 3, 2002
Messages
51
I have a percentage worked out for my students' test and homework scores in an Access database of my students and their performances. Is it possible, presumably using some simple VBA, to apply a grade as a new field, which depends on how good the percentage is?

e.g. A student scores 40 out of 50, which works out to be 80%.
Given:

80% is an A,
70% is a B,
60% is a C, etc.

The grade field should show an A.

Any help would be much appreciated.
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
In a module add the following code and save the module with a differnt name than the function.
From a query you would call it with something like Score:GetScores([MyPercentage]) where [MyPercentage] is the field where you have worked out your pecentage.

Code:
Function GetScores(dblScoreIn As Double)
Select Case dblScoreIn
Case Is >= 80
   GetScores = "A"
Case Is >= 70
   GetScores = "B"
Case Is >= 60
   GetScores = "C"
Case Else
   GetScores = "Fail"
End Select
End Function
 
Upvote 0

Forum statistics

Threads
1,221,575
Messages
6,160,603
Members
451,657
Latest member
Ang24

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top