View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
JE McGimpsey JE McGimpsey is offline
external usenet poster
 
Posts: 4,624
Default Days in a month Function

One way:


Public Function DaysInMonth(vDate As Variant) As Variant
Dim nDaysInMonth As Long
On Error GoTo ErrHandler
nDaysInMonth = Day(DateSerial(Year(vDate), Month(vDate) + 1, 0))
DaysInMonth = nDaysInMonth
Continue:
On Error GoTo 0
Exit Function
ErrHandler:
DaysInMonth = CVErr(xlErrValue)
Resume Continue
End Function



In article ,
"Marek" wrote:

Thanks - gives me a clue. How could I do this purely from code - I don't
have a cell reference for the date.