Public Function EasterDate(ByVal iYear As Integer) As Date
' Developed By Claudio Briguglio
Dim D As Integer
D = (((255 - 11 * (iYear Mod 19)) - 21) Mod 30) + 21
EasterDate = DateSerial(iYear, 3, 1) + D + (D > 48) + 6 - ((iYear + iYear \ 4 + _
D + (D > 48) + 1) Mod 7)
End Function
Come calcolare la data della Pasqua. VBA function.
Di seguito il codice della funzione VBA per calcolare il giorno della Pasqua. L'anno (iYear, variabile di tipo Integer) è l'unico parametro.
4 commenti:
Ottimo Grazie !!!!!
Mi spiace segnalare che dall'anno 2100 la pasqua viene calcolata sbagliata, dal 2014 al 2100 tutto regolare ...
come serve sapere la data della pasqua oltre il 2100?
Magari può interessare .. ho scritto un codice per il calcolo se un giorno è festivo tenendo conto delle festività FISSE (capodanno .. epifania .. ecc .. oltre che Lunedì dell'Angelo
Public Function Festivo(iData As Date) As Boolean
' Verifica se una DATA è FESTIVO (Sabato/Domenica o Festività)
If Weekday(iData, vbMonday) > 5 Then
Festivo = True
Exit Function
End If
Dim ggFestivi As String
Dim iAnno As Integer
iAnno = Year(iData)
' imposta stringa festivi FISSI calendario italiano
ggFestivi = "01/01,06/01,25/04,01/05,02/06,15/08,01/11,08/12,25/12,26/12"
' Aggiunge Lunedi' di Pasquetta (data mobile)
ggFestivi = ggFestivi & Format(Round(DateSerial(iAnno, 4, 1) / 7 + ((19 * (iAnno Mod 19) - 7) Mod 30) * 0.14, 0) * 7 - 6 + 1, "dd/mm")
' Verifica se festivo
If InStr(1, Format(iData, "dd/mm"), ggFestivi, vbTextCompare) <> 0 Then
Festivo = True
Else
Festivo = False
End If
End Function
Posta un commento