Code eingefügt mit Syntaxhighlighter 1.15
Option Explicit
Sub Werktage()
Dim ADat As Date
Dim EDat As Date
Dim I As Date
Dim At As Integer
Dim D As Integer
Dim Yr As Integer
'Feiertage
Dim Ostern As Date
Dim Neujahr As Date
Dim H3Könge As Date
Dim Rosenmontag As Date
Dim Karfreitag As Date
Dim Ostermontag As Date
Dim Christi_Himmelfahrt As Date
Dim Pfingstmontag As Date
Dim Fronleichnam As Date
Dim Maifeiertag As Date
Dim Nationalfeiertag As Date
Dim Erntedankfest As Date
Dim Reformationstag As Date
Dim Allerheiligen As Date
Dim Volkstrauertag As Date
Dim Buss_und_Betag As Date
Dim Totensonntag As Date
Dim erste_Weihnachtstag As Date
Dim zweiter_Weihnachtstag As Date
ADat = Range("A1").Value
EDat = Range("B1").Value
For I = ADat To EDat
Yr = Year(I)
D = (((255 - 11 * (Yr Mod 19)) - 21) Mod 30) + 21
Ostern = DateSerial(Yr, 3, 1) + D + (D > 48) + 6 - _
((Yr + Yr \ 4 + D + (D > 48) + 1) Mod 7)
'von Ostern abhängige Feiertage
Rosenmontag = Ostern - 48
Karfreitag = Ostern - 2
Ostermontag = Ostern + 1
Christi_Himmelfahrt = Ostern + 39
Pfingstmontag = Ostern + 50
Fronleichnam = Ostern + 60
'Feste Feiertage
Neujahr = DateSerial(Year(I), 1, 1)
H3Könge = Neujahr + 5
Maifeiertag = DateSerial(Year(I), 5, 1)
Nationalfeiertag = DateSerial(Year(I), 10, 3)
Erntedankfest = DateSerial(Year(I), 10, 1) + 7 - Weekday(DateSerial(Year(I), 10, 1), vbMonday)
Reformationstag = DateSerial(Year(I), 10, 31)
Allerheiligen = DateSerial(Year(I), 11, 1)
Volkstrauertag = DateSerial(Year(I), 12, 25) - Weekday(DateSerial(Year(I), 12, 25), vbMonday) - 35
Buss_und_Betag = DateSerial(Year(I), 12, 25) - Weekday(DateSerial(Year(I), 12, 25), vbMonday) - 32
Totensonntag = DateSerial(Year(I), 12, 25) - Weekday(DateSerial(Year(I), 12, 25), vbMonday) - 28
erste_Weihnachtstag = DateSerial(Year(I), 12, 25)
zweiter_Weihnachtstag = DateSerial(Year(I), 12, 26)
If I = Ostern Then GoTo Ende
If I = Neujahr Then GoTo Ende
If I = H3Könge Then GoTo Ende
If I = Rosenmontag Then GoTo Ende
If I = Karfreitag Then GoTo Ende
If I = Ostermontag Then GoTo Ende
If I = Christi_Himmelfahrt Then GoTo Ende
If I = Pfingstmontag Then GoTo Ende
If I = Fronleichnam Then GoTo Ende
If I = Maifeiertag Then GoTo Ende
If I = Nationalfeiertag Then GoTo Ende
If I = Erntedankfest Then GoTo Ende
If I = Reformationstag Then GoTo Ende
If I = Allerheiligen Then GoTo Ende
If I = Volkstrauertag Then GoTo Ende
If I = Buss_und_Betag Then GoTo Ende
If I = Totensonntag Then GoTo Ende
If I = erste_Weihnachtstag Then GoTo Ende
If I = zweiter_Weihnachtstag Then GoTo Ende
If Weekday(I, vbMonday) > 5 Then GoTo Ende
At = At + 1
Ende:
Next
MsgBox ("es sind " & At & " Arbeitstage")
End Sub