Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Public function in Personal.xls Ardus Petus Excel Programming 8 June 10th 06 12:26 PM
Using A Public Function / carl Excel Worksheet Functions 1 April 6th 06 09:13 PM
public function tom mcdonald[_4_] Excel Programming 2 October 10th 05 01:51 PM
Make Function Public Andibevan[_2_] Excel Programming 3 June 30th 05 04:46 PM
Public Function Monty Excel Discussion (Misc queries) 9 December 24th 04 06:35 PM


All times are GMT +1. The time now is 07:07 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"