View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default Creating Custom Function - A Little Help Please!

The 1900 error was deliberately included for compatibility with Lotus's
previous error.
Excel's worksheet will only work back to 1900, but VBA Dates are valid back
the year 100.
However, given the number of changes to the calendars since then, I would
not put much faith in reality v. calculation before the 1800s.

NickHK

"Randy Harmelink" wrote in message
oups.com...
Tom Ogilvy wrote:
Public Function LeapYear(yr as Long) as Boolean
LeapYear = (month(date(yr,2,29)) = 2)
End Sub


I was going to offer something similar (subtract 1 from 3/1 of the year
to see if the day is 28 or 29). However, basing the leap year decision
on whether the year has a 2/29 date appears to incorrectly identify
1900 as a leap year? EXCEL's date function claims there is a date of
2/29/1900.

Plus, it only works back to 1900. Which may or may not be a problem,
depending on how it is being used.