LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
Andy123
 
Posts: n/a
Default Public Function Problems


Hi,

I am very new to VBA and am attempting to use a public Function without
much luck.

What I need is I have 6 test results in columns C to H and I need a
Public Function to add the scores up make certain divisions and output
a mark e.g Merit for the score they achieved. I have attempted it in
the code below and have chopped and changed thing so much I am now
totally confused.

This is the code...


Code:
--------------------

Option Explicit

Public Function Grade(cell As Range) As String

Dim dblTest1 As Double
Dim dblTest2 As Double
Dim dblTest3 As Double
Dim dblTest4 As Double
Dim dblTest5 As Double
Dim dblProject As Double
Dim dblTotal As Double

Do Until "$I" & ActiveCell.Row = ""
If "$H" & ActiveCell.Row = 0 Then
Grade = "No Project"
Else
dblTest1 = cell.Offset(0, -6).Value
dblTest2 = cell.Offset(0, -5).Value
dblTest3 = cell.Offset(0, -4).Value
dblTest4 = cell.Offset(0, -3).Value
dblTest5 = cell.Offset(0, -2).Value
dblProject = cell.Offset(0, -1).Value

dblTest1 = (dblTest1 / 20)
dblTest2 = (dblTest2 / 20)
dblTest3 = (dblTest3 / 10)
dblTest4 = (dblTest4 / 10)
dblTest5 = (dblTest5 / 5)
dblProject = (dblProject / 2)

dblTotal = dblTest1 + dblTest2 + dblTest3 + dblTest4 _
+ dblTest5 + dblProject

Select Case dblTotal
Case Is < 40
Grade = "Not Achieved"
Case Is < 60
Grade = "Pass"
Case Is < 80
Grade = "Merit"
Case Is < 100
Grade = "Distinction"
Case Else
Grade = "Error"
End Select

End If
Loop
End Function

--------------------


Any help anyone can offer would be great! :)

Thanks

Andy


--
Andy123
------------------------------------------------------------------------
Andy123's Profile: http://www.excelforum.com/member.php...o&userid=29886
View this thread: http://www.excelforum.com/showthread...hreadid=495902

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
problems with RATE function returning #NUM [email protected] Excel Worksheet Functions 2 July 29th 05 10:23 AM
Public Function to Return ColorIndex Fries Excel Discussion (Misc queries) 2 July 28th 05 09:23 AM
Automatically up date time in a cell Mark Excel Discussion (Misc queries) 5 May 12th 05 12:26 AM
opening up an english excel sheet onto a french verions - problems with edate function [email protected] Excel Discussion (Misc queries) 0 February 20th 05 01:37 PM
HOW CAN I GET OFFICE 2003 EXCEL BASIC TO NEST FUNCTIONS LIKE EXCE. Robert AS Excel Worksheet Functions 4 December 2nd 04 10:49 AM


All times are GMT +1. The time now is 01:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"