While running a Sub Procedure "Line by Line" with "F8" why does it Jumps to a Function (UDF)

anilsharaf

New Member
Joined
Apr 8, 2014
Messages
38
Office Version
  1. 2007
Platform
  1. Windows
This is UDF
Function PassOrFailAnvl(Allsub As Range, _
Optional Practicle As Range) As String
'First make result with theory marks and
'After making result add the Project marks
'only to calculate percentage.

'if U want to see this run line by line like a SubProcedure
'Put an apostrophy before select case and run on sheet

Dim A, B, C, x As Variant
A = Application.WorksheetFunction.CountIf(Allsub, "abs")
B = Application.WorksheetFunction.CountIf(Allsub, "<25")
'C = Application.WorksheetFunction.CountIf(Practicle, "<8")

x = A + B + C
Select Case x
Case Is < 1
PassOrFailAnvl = "PASS"
Case Is < 3
PassOrFailAnvl = "SUPPL"
Case Is > 2
PassOrFailAnvl = "FAIL"
End Select


End Function





And this is Procedure


Sub PassOrFailSub()
Dim mt(6), mp(6) 'MarksTheory,MarksPracticle
Dim i, j, k, l, m, n As Integer


Set Tc = Application.InputBox(Prompt:="Select Total Cell", Type:=8)
Colm = Tc.Column
lastrow = Cells(65536, Colm).End(xlUp).Row
Tc.Select


'mt = MarksOfTheory
Do Until Selection = ""


i = 1
For j = -18 To -1 Step 3
'nt = ActiveCell.Offset(0, j)
mt(i) = ActiveCell.Offset(0, j) 'MarksTreoryArray
If mt(i) = "abs" Then
mt(i) = 0: End If
i = i + 1: If i = 7 Then Exit For
Next j


'mp= MarksOfPracticle
k = 1
For l = -17 To -1 Step 3
'nt = ActiveCell.Offset(0, j)
mp(k) = ActiveCell.Offset(0, l) 'MarksPracticleArray
If mp(k) = "abs" Then
mp(k) = 0: End If
k = k + 1: If k = 7 Then Exit For
Next l


u = LBound(mt)
'Check if MarksTheory is smaller than PassingMarks(25)


y = 0
For m = LBound(mt) To UBound(mt)
If mt(m) < 25 Then
y = y + 1
End If
Next m

'Check if MarksPracticle is smaller than PassingMarks(8)
Z = 0
For n = LBound(mp) To UBound(mp)
If mp(n) < 8 Then
Z = Z + 1
End If
Next n

x = y + Z

Select Case x
Case Is < 1
PassFail = "PASS"
Case Is < 3
PassFail = "SUPPL"
Case Is > 2
PassFail = "FAIL"
End Select

ActiveCell.Offset(0, 1) = PassFail

ActiveCell.Offset(1, 0).Select
Loop

End Sub
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Try setting calculation mode to manual at the beginning of the Sub and back to automatic at the end:
Code:
Application.Calculation = xlCalculationManual
'
'
'
'
application.calculation =xlCalculationAutomatic
 
Upvote 0
Solution
Is it possible that the Sub is putting values into cell that are precedents of a formula that uses the UDF?
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,215
Members
448,554
Latest member
Gleisner2

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