View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default User defined function to count pay days in current month.

Public Function paydays2(lyear As Long, _
lmonth As Long, dtfirstpayday, lpayperiod)
Dim dtStart As Date, dtEnd As Date
Dim dtStart1 As Date, dtEnd1 As Date
dtStart1 = dtfirstpayday
dtEnd1 = DateSerial(lyear, lmonth, 0)
dtEnd = DateSerial(lyear, lmonth + 1, 0)
lNumdays = dtEnd1 - dtStart1
lpays = lNumdays \ lpayperiod
dtStart = dtStart1 + lpayperiod * lpays
lNumdays = dtEnd - dtStart
paydays = lNumdays \ lpayperiod + _
IIf(month(dtStart1) = lmonth And year(dtStart1) = _
lyear, 1, 0)
End Function

--
Regards,
Tom Ogilvy


"dbmathis" wrote in
message ...

Tom,

Actually that UDF is wonderful! I was wondering if you could make it
inclusive to handle a situation like the following?

=paydays2(2005, 8, "8/1/2005", 14)

and produce a 3 including the 1st of August in the results?

If not I can work around that :). The UDF works great though! Thank you
a 1000 billion times!


--
dbmathis
------------------------------------------------------------------------
dbmathis's Profile:

http://www.excelforum.com/member.php...o&userid=26735
View this thread: http://www.excelforum.com/showthread...hreadid=399918