AW: Datumsbereich mit UserForm Auswählen
01.09.2020 16:42:45
Rudi
in der UF:
Private Sub CommandButton1_Click()
Dim lngColumn As Long, lngRow As Long
lngColumn = ComboBox1.ListIndex + 25
Dim dasDatum As Date, vonDatum As Date, bisDatum As Date
lngRow = ComboBox2.ListIndex + 5
vonDatum = ComboBox2
bisDatum = ComboBox3
For dasDatum = vonDatum To bisDatum
If dasDatum Mod 7 1 Then
If Not istFeiertag(dasDatum) Then
With Sheets("schichten").Cells(lngRow, lngColumn)
Select Case ComboBox4
Case "U", "ÜB": If LCase(.Value) "fs" Then .Value = ComboBox4
Case "K": .Value = "K"
End Select
End With
End If
End If
lngRow = lngRow + 1
Next dasDatum
End Sub
In ein Modul:
Function istFeiertag(datum) As Boolean
Dim d As Integer, iJahr As Integer, OSo As Date
iJahr = Year(datum)
d = (((255 - 11 * (iJahr Mod 19)) - 21) Mod 30) + 21
OSo = DateSerial(iJahr, 3, 1) + d + (d > 48) + 6 - ((iJahr + iJahr \ 4 + d + (d > 48) + 1) _
Mod 7)
Select Case datum
Case OSo - 2, _
OSo + 1, _
OSo + 39, _
OSo + 50, _
OSo + 60, _
DateSerial(iJahr, 1, 1), _
DateSerial(iJahr, 5, 1), _
DateSerial(iJahr, 10, 3), _
DateSerial(iJahr, 11, 1), _
DateSerial(iJahr, 12, 25), _
DateSerial(iJahr, 12, 26)
istFeiertag = True
End Select
'Karfreitag=Ostersonntag-2
'Ostermontag=Ostersonntag+1
'Chr.Himmelfahrt=Ostersonntag+39
'Pfingstmontag=Ostersonntag+50
'Fronleichnam=Ostersonntag+60
End Function