H
Huyeote
Dear all,
The following function is a sample in Excel's help. When I use it in a
worksheet giving a cell reference as the argument (the cell contains a
formula which refers to other cells), the function runs twice. I mean
when the line End Function was executed, it just went back to the first
line (_If_NumberArg_<_0_Then_) and run all lines
through again. I also have a few DIY functions that run even four times
when used in worksheet.
Code:
--------------------
Function CalculateSquareRoot(NumberArg As Double) As Double
If NumberArg < 0 Then ' Evaluate argument.
Exit Function ' Exit to calling procedure.
Else
CalculateSquareRoot = Sqr(NumberArg) ' Return square root.
End If
End Function
--------------------
Can anyone tell me why is this phenomenon and how to stop this
happening?
Many thanks,
Huyeote
The following function is a sample in Excel's help. When I use it in a
worksheet giving a cell reference as the argument (the cell contains a
formula which refers to other cells), the function runs twice. I mean
when the line End Function was executed, it just went back to the first
line (_If_NumberArg_<_0_Then_) and run all lines
through again. I also have a few DIY functions that run even four times
when used in worksheet.
Code:
--------------------
Function CalculateSquareRoot(NumberArg As Double) As Double
If NumberArg < 0 Then ' Evaluate argument.
Exit Function ' Exit to calling procedure.
Else
CalculateSquareRoot = Sqr(NumberArg) ' Return square root.
End If
End Function
--------------------
Can anyone tell me why is this phenomenon and how to stop this
happening?
Many thanks,
Huyeote