Excel & vba: quanti giorni ha un mese?
Direttamente da mamma Microsoft la soluzione a questo annoso dilemma:
Function DaysInMonth(MyDate) As Long
Dim NextMonth As Date
Dim EndOfMonth As Date
NextMonth = DateAdd("m", 1, MyDate)
EndOfMonth = NextMonth - DatePart("d", NextMonth)
DaysInMonth = DatePart("d", EndOfMonth)
End Function
Va al primo giorno del mese successivo e poi toglie un giorno. Genialacci.
Leave a Reply