Visual Basic Editor in Excel

M

miss noname

I have the following code. I am passing parameters and calling subroutines. I
don't know why this program cannot run.

Sub gradecombo_ko()

Call numgrade_ko(ByVal row as Integer)

Call letgrade_ko (ByVal row as Integer)

End Sub
----------------------------------------------------------------

Sub numgrade_ko(ByVal row As Integer)
Dim MT As Single
Dim FE As Single
Dim NG As Single

Worksheets("Marks").Activate

row = 5

Do Until (IsEmpty(Cells(row, 1)))

MT = Cells(row, 8)
FE = Cells(row, 9)

NG = (75 * (FE / 100)) + (25 * (MT / 90))

NG = Round(NG, 0)

Cells(row, 10) = NG

row = row + 1

Loop

End Sub
________________________________________________________________

Sub letgrade_ko(ByVal row As Integer)
Dim A1 As Single
Dim A2 As Single
Dim A3 As Single
Dim A4 As Single
Dim A5 As Single
Dim NG As Single
Dim TA As Single
Dim LG As String

Worksheets("Marks").Activate

row = 5

Do Until (IsEmpty(Cells(row, 1)))
A1 = Cells(row, 3)
A2 = Cells(row, 4)
A3 = Cells(row, 5)
A4 = Cells(row, 6)
A5 = Cells(row, 7)
NG = Cells(row, 10)

TA = ((A1 + A2 + A3 + A4 + A5) / 60) * 100

If (NG < 50) Then

If (40 <= NG) And (NG <= 49) Then
LG = "E"
ElseIf (0 <= NG) And (NG <= 39) Then
LG = "F"
End If

Else

If (TA >= 75) Then

If (85 <= NG) And (NG <= 100) Then
LG = "A+"
ElseIf (80 <= NG) And (NG < 85) Then
LG = "A"
ElseIf (75 <= NG) And (NG < 80) Then
LG = "A-"
ElseIf (70 <= NG) And (NG < 75) Then
LG = "B+"
ElseIf (66 <= NG) And (NG < 70) Then
LG = "B"
ElseIf (60 <= NG) And (NG < 66) Then
LG = "C+"
ElseIf (55 <= NG) And (NG < 60) Then
LG = "C"
ElseIf (50 <= NG) And (NG < 55) Then
LG = "D+"
End If

ElseIf (50 <= TA) And (TA < 75) Then

If (90 <= NG) And (NG <= 100) Then
LG = "A+"
ElseIf (85 <= NG) And (NG < 90) Then
LG = "A"
ElseIf (80 <= NG) And (NG < 85) Then
LG = "A-"
ElseIf (75 <= NG) And (NG < 80) Then
LG = "B+"
ElseIf (70 <= NG) And (NG < 75) Then
LG = "B"
ElseIf (66 <= NG) And (NG < 70) Then
LG = "C+"
ElseIf (60 <= NG) And (NG < 66) Then
LG = "C"
ElseIf (55 <= NG) And (NG < 60) Then
LG = "D+"
ElseIf (50 <= NG) And (NG < 55) Then
LG = "D"
End If

Else

If (90 <= NG) And (NG <= 100) Then
LG = "A"
ElseIf (85 <= NG) And (NG < 90) Then
LG = "A-"
ElseIf (80 <= NG) And (NG < 85) Then
LG = "B+"
ElseIf (75 <= NG) And (NG < 80) Then
LG = "B"
ElseIf (70 <= NG) And (NG < 75) Then
LG = "C+"
ElseIf (66 <= NG) And (NG < 70) Then
LG = "C"
ElseIf (60 <= NG) And (NG < 66) Then
LG = "D+"
ElseIf (50 <= NG) And (NG < 60) Then
LG = "D"
End If

End If

End If

Cells(row, 11) = LG

row = row + 1

Loop

End Sub
 
R

RWN

When you say "cannot run", what do you mean?
If you're getting an runtime error, what is the message & where's it failing?
Or, are you getting invalid results?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top