I am trying to calculate the number of days for a dedicated year based on a date, e.g. 2015 using excel vba. 2015 should have 365 days which is a non-leap year and 2016 are 366 which is a leap year.
A date would be e.g. 01.02.2015 and based on the year 2015 I would like to know how many days are in 2015. Is there a way doing it in vba?
or
Public Function daysinyear(lngyear As Long) As Long
daysinyear = DateDiff("d", DateSerial(lngyear, 1, 1), DateSerial(lngyear + 1, 1, 1))
End Function