View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default 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