Re: Counting the Dates
- From: "Rick Rothstein \(MVP - VB\)" <rickNOSPAMnews@xxxxxxxxxxxxxxxxx>
- Date: Sun, 27 Jan 2008 13:30:32 -0500
Function Index(Mnth As String, Dy As Long) As Long
Index = DatePart("y", DateValue(Mnth & " " & CStr(Dy) & ",2000"))
End Function
I don't use it often, but wouldn't DateSerial make more sense in the above function, and pass the Mnth by number instead of as a string?
I figured Webbiz would want to enter data in the same format that it is stored in the file (where the month is stored as a name). And, of course, as the function was set up, he only needs to enter a minimum of the first three letters of the month name for the function to work. However, we can expand the function to let the month be entered as a name (same minimum of first three letters) or as a number...
Function Index(Mnth As String, Dy As Long) As Long
If Mnth Like String(Len(Mnth), "#") Then
Index = DatePart("y", DateSerial(2000, Mnth, Dy))
Else
Index = DatePart("y", DateValue(Mnth & " " & CStr(Dy) & ",2000"))
End If
End Function
Rick
.
- Follow-Ups:
- Re: Counting the Dates
- From: Webbiz
- Re: Counting the Dates
- References:
- Counting the Dates
- From: Webbiz
- Re: Counting the Dates
- From: Rick Rothstein \(MVP - VB\)
- Re: Counting the Dates
- From: Robert Morley
- Counting the Dates
- Prev by Date: Re: Metafile, Should I?
- Next by Date: Re: Counting the Dates
- Previous by thread: Re: Counting the Dates
- Next by thread: Re: Counting the Dates
- Index(es):
Relevant Pages
|