I am starting to teach Visual Basic for Applications in Excel tonight,
and wanted to have some code for the students to try, and here it is:
Function AvgDaysInMonth()
AvgDaysInMonth = 365.25 / 12
End Function
Function DaysInMonth(Month As Integer, Year As Integer)
DaysInMonth = DateSerial(Year, Month + 1, 1) - DateSerial(Year, Month, 1)
End Function
Function IsLeapYear(Year As Integer)
If DaysInMonth(2, Year) = 29 Then
IsLeapYear = True
Else
IsLeapYear = False
End If
End Function
Function FindNextLeapYear(Year As Integer)
For Counter = 0 To 3
If IsLeapYear(Year + Counter) = True Then
FindNextLeapYear = Year + Counter
End If
Next Counter
End Function