AW: automatische vorbelegung
19.04.2021 09:55:36
Nepumuk
Hallo Stefan,
teste mal:
Option Explicit
Public Sub Insert_X()
Const START_ROW As Long = 4
Const START_COLUMN As Long = 3
Const END_COLUMN As Long = 33
Const INSERT_VALUE As String = "X"
Dim lngMonth As Long
Dim lngRow As Long, lngColumn As Long
Application.EnableEvents = False
For lngMonth = 1 To 12
With Worksheets(MonthName(lngMonth))
For lngRow = START_ROW To .Rows.Count
If .Cells(lngRow, 1).MergeCells Then Exit For
Next
lngRow = lngRow - 1
For lngColumn = START_COLUMN To END_COLUMN
If IsDate(.Cells(2, lngColumn).Value) Then
If Weekday(.Cells(2, lngColumn).Value) = vbSaturday Or _
Weekday(.Cells(2, lngColumn).Value) = vbSunday Then
.Range(.Cells(START_ROW, lngColumn), _
.Cells(lngRow, lngColumn)).Value = INSERT_VALUE
Else
If Not IsError(Application.Match(CLng(.Cells(2, lngColumn).Value), _
Worksheets("VBA").Columns(2), False)) Then _
.Range(.Cells(START_ROW, lngColumn), _
.Cells(lngRow, lngColumn)).Value = INSERT_VALUE
End If
End If
Next
End With
Next
Application.EnableEvents = True
End Sub
Gruß
Nepumuk