![]() |
Function runs more than once
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 -- Huyeote ------------------------------------------------------------------------ Huyeote's Profile: http://www.excelforum.com/member.php...o&userid=13894 View this thread: http://www.excelforum.com/showthread...hreadid=549330 |
Function runs more than once
There are some explanations which might help at
http://www.DecisionModels.com/calcsecretsj.htm Charles ______________________ Decision Models FastExcel 2.2 Beta now available www.DecisionModels.com "Huyeote" wrote in message ... 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 -- Huyeote ------------------------------------------------------------------------ Huyeote's Profile: http://www.excelforum.com/member.php...o&userid=13894 View this thread: http://www.excelforum.com/showthread...hreadid=549330 |
All times are GMT +1. The time now is 05:01 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com