Reputation: 397
Please find my below VBA code.
Private Function NBFCYield(ByRef NOD As Variant, ByRef Total_Interest As Variant, ByRef Average_Loan As Variant)
Yield = Total_Interest * 365
Yield = Yield / NOD
Yield = Yield / 100
If Yield <> 0 Then
NBFCYield = Yield / Average_Loan
Else
NBFCYield = 0
End If
End Function
Sub macro1()
Cells(8, 2).ClearContents
End Sub
In my above Sub Macro1 I am not mentioned or call or instructed anything which use Function NBFCYield but still the function is triggered by Sub macro1. Please help me.
Upvotes: 1
Views: 49
Reputation: 1049
Use this code - it should prevent triggering UDFs:
Sub macro1()
Application.EnableEvents = False
Application.Calculation = xlManual
Cells(8, 2).ClearContents
Application.EnableEvents = True
Application.Calculation = xlAutomatic
end sub
If you are trying to determine what is calling the function you can try to use the following in the function:
Select Case TypeName(Application.Caller)
Case "Range"
v = Application.Caller.Address
Case "String"
v = Application.Caller
end select
msgbox v
Upvotes: 1