Habe dieses Makro gefunden...
16.01.2022 17:21:45
Walter
Hallo zusammen,
habe gerade dieses Makro gefunden:
Visual Basic-Quellcode
Option Explicit
Option Private Module
Sub Aendern()
Application.EnableCancelKey = xlDisabled
On Error Resume Next
Application.ScreenUpdating = False
Sheets("Zeitnachweis").Unprotect passw
Week_end
Week_day
Sheets("Zeitnachweis").Protect passw
Application.ScreenUpdating = True
End Sub
Private Sub Week_end()
Application.EnableCancelKey = xlDisabled
Dim cell As Object
On Error Resume Next
Dim Zeile As Range
For Each cell In Worksheets("Zeitnachweis").Range("B13:B743")
If Weekday(cell, vbMonday) = 7 Then
cell.Font.ColorIndex = 3
ElseIf Weekday(cell, vbMonday) = 6 Then
cell.Font.ColorIndex = 5
Else
cell.Font.ColorIndex = 0
End If
Next cell
End Sub
Private Sub Week_day()
Application.EnableCancelKey = xlDisabled
Dim cell As Object
On Error Resume Next
Dim Zeile As Range
For Each cell In Worksheets("Zeitnachweis").Range("B13:B743")
If cell.Value = Sheets("Feiertage").Range("A1").Value Then
cell.Font.ColorIndex = 3
ElseIf cell.Value = Sheets("Feiertage").Range("A2").Value Then
cell.Font.ColorIndex = 3
ElseIf cell.Value = Sheets("Feiertage").Range("A3").Value Then
cell.Font.ColorIndex = 3
ElseIf cell.Value = Sheets("Feiertage").Range("A4").Value Then
cell.Font.ColorIndex = 3
ElseIf cell.Value = Sheets("Feiertage").Range("A5").Value Then
cell.Font.ColorIndex = 3
ElseIf cell.Value = Sheets("Feiertage").Range("A6").Value Then
cell.Font.ColorIndex = 3
ElseIf cell.Value = Sheets("Feiertage").Range("A7").Value Then
cell.Font.ColorIndex = 3
ElseIf cell.Value = Sheets("Feiertage").Range("A8").Value Then
cell.Font.ColorIndex = 3
ElseIf cell.Value = Sheets("Feiertage").Range("A9").Value Then
cell.Font.ColorIndex = 3
ElseIf cell.Value = Sheets("Feiertage").Range("A10").Value Then
cell.Font.ColorIndex = 3
ElseIf cell.Value = Sheets("Feiertage").Range("A11").Value Then
cell.Font.ColorIndex = 3
ElseIf cell.Value = Sheets("Feiertage").Range("A12").Value Then
cell.Font.ColorIndex = 3
ElseIf cell.Value = Sheets("Feiertage").Range("A13").Value Then
cell.Font.ColorIndex = 3
ElseIf cell.Value = Sheets("Feiertage").Range("A14").Value Then
cell.Font.ColorIndex = 3
ElseIf cell.Value = Sheets("Feiertage").Range("A15").Value Then
cell.Font.ColorIndex = 3
ElseIf cell.Value = Sheets("Feiertage").Range("A16").Value Then
cell.Font.ColorIndex = 3
ElseIf cell.Value = Sheets("Feiertage").Range("A17").Value Then
cell.Font.ColorIndex = 3
ElseIf cell.Value = Sheets("Feiertage").Range("A18").Value Then
cell.Font.ColorIndex = 3
ElseIf cell.Value = Sheets("Feiertage").Range("A19").Value Then
cell.Font.ColorIndex = 3
ElseIf cell.Value = Sheets("Feiertage").Range("A20").Value Then
cell.Font.ColorIndex = 3
ElseIf cell.Value = Sheets("Feiertage").Range("A21").Value Then
cell.Font.ColorIndex = 3
ElseIf cell.Value = Sheets("Feiertage").Range("A22").Value Then
cell.Font.ColorIndex = 3
ElseIf cell.Value = Sheets("Feiertage").Range("A23").Value Then
cell.Font.ColorIndex = 3
ElseIf cell.Value = Sheets("Feiertage").Range("A24").Value Then
cell.Font.ColorIndex = 3
ElseIf cell.Value = Sheets("Feiertage").Range("A25").Value Then
cell.Font.ColorIndex = 3
Else
End If
Next cell
End Sub
ich würde auch die Tabelle Feiertage2 erstellen und angefangen in A2
die entsprechenden Feiertage zu Plazieren.
In A1 soll immer das aktuelle Jahr aus N3 genommen werden.
mfg walter