Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Loop w/ Public Function as arguement
I am trying to create a loop to count how many times a date function I have
written is performed before a criteria is met. I am receiving a ByRef error, and do no know how to fix it. Here is the code: Public Function myfunc(testdate, maturitydate) counter = 0 Do While maturitydate testdate testdate = nextcdate(testdate) counter = counter + 1 Loop myfunc = counter End Function Thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Loop w/ Public Function as arguement
Hard to tell without the signature of the function "nextcdate".
Also, it would be more clear if you declared data types in the arguments and return value of the functions. Maybe, it is: Public Function myfunc(testdate as date, maturitydate as date) as long Also, read the Help on the difference between "ByRef" and "ByVal" arguments. Note "ByRef" is the default. Depending on where this is called from and how you intend these functions to be used, you may be changing values inadvertently. NickHK "wienmichael" wrote in message ... I am trying to create a loop to count how many times a date function I have written is performed before a criteria is met. I am receiving a ByRef error, and do no know how to fix it. Here is the code: Public Function myfunc(testdate, maturitydate) counter = 0 Do While maturitydate testdate testdate = nextcdate(testdate) counter = counter + 1 Loop myfunc = counter End Function Thanks |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Loop w/ Public Function as arguement
It look as if nextcdate has typed arguments, such as
Function nextcdate(inDate as Date) but you are trying to pass a variant to it. Declare the types of the myfunc function and ensure that they all match. It is far better to declare the type of an argument, even if you intend for it to be variant. -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "wienmichael" wrote in message ... I am trying to create a loop to count how many times a date function I have written is performed before a criteria is met. I am receiving a ByRef error, and do no know how to fix it. Here is the code: Public Function myfunc(testdate, maturitydate) counter = 0 Do While maturitydate testdate testdate = nextcdate(testdate) counter = counter + 1 Loop myfunc = counter End Function Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Public function in Personal.xls | Excel Programming | |||
Using A Public Function / | Excel Worksheet Functions | |||
public function | Excel Programming | |||
Make Function Public | Excel Programming | |||
Public Function | Excel Discussion (Misc queries) |