Hi Leute,
ich habe einen VBA-Code bei dem eine Terminübersicht innerhalb einer Matrix möglich ist. Dabei wird auf einen Kalender bezogen, der in Zeile 6 zu finden ist. Über einen Button soll der erste freie verfügbare Tag erkannt werden. Jetzt kann dieser Code schon erkennen, dass Samstage und Sonntage als freie Tage berücksichtigt werden sollen. Allerdings erkennt er die Feiertage noch nicht, so dass mir Verfügbarkeit angezeigt wird, obwohl dies kein Arbeitstag sein soll. Diese habe ich in einem anderen Tabellenblatt hinterlegt. Anbei der entsprechende Ausschnitt des Codes:
For Each col In rng.Columns
With wks
If Not Weekday(.Cells(6, col.column).Value, vbMonday) > 5 And IsError(IsHoliday(.Cells(6, col.column).Value)) And IsError(Is2Holiday(.Cells(6, col.column).Value)) And IsError(Is3Holiday(.Cells(6, col.column).Value)) = True Then
If col.Cells.Count = Application.WorksheetFunction.CountBlank(col) Then
MSGBOX "Volle Verfügbarkeit am " & .Cells(5, col.column) & ", den " & .Cells(6, col.column)
Exit Sub
End If
End If
End With
Next
'
MSGBOX "Es gibt keine komplett leere Spalte in der Ressourcenplanung"
End Sub
Function IsHoliday(d As Date) As Variant
Dim v As Variant
v = Application.Match(CDbl(d), ThisWorkbook.Worksheets("Public Holidays").Columns(1), 0)
IsHoliday = v
End Function
Function Is2Holiday(d As Date) As Variant
Dim v As Variant
v = Application.Match(CDbl(d), ThisWorkbook.Worksheets("Public Holidays").Columns(3), 0)
Is2Holiday = v
End Function
Function Is3Holiday(d As Date) As Variant
Dim v As Variant
v = Application.Match(CDbl(d), ThisWorkbook.Worksheets("Public Holidays").Columns(5), 0)
Is3Holiday = v
End Function
Vielen Dank für eure Hilfe!
|