Datenübernahme aus Uform in Kalenderblatt
07.05.2025 12:43:56
Horst Gernert
Der VBA Code läuft ohne Fehler durch , es wird aber nichts ins Kalenderblatt übertragen
kann mir da jemand helfen. In der Tabelle gibt es ein Button um Urlaub einzutragen
https://www.herber.de/bbs/user/177358.xlsm
'Urlaub in Kalender eintragen
Private Sub CommandButton2_Click()
Dim str_mitarbeiter As String
Dim dat_von As Date
Dim dat_bis As Date
Dim str_kuerzel As String
Dim obj_wks_ziel As Worksheet
Dim lng_spalte_von As Long
Dim lng_spalte_bis As Long
Dim rng_fund As Range
Dim lng_zeile As Long
Dim lng_Spalte As Long
Dim lng_zaehler As Long
str_mitarbeiter = Me.ComboBox1
dat_von = Me.TextBox1
dat_bis = Me.TextBox2
str_kuerzel = Me.ListBox1
Set obj_wks_ziel = ThisWorkbook.Worksheets("Personalplaner")
With obj_wks_ziel
For lng_zaehler = 9 To .Rows.Count
If .Cells(lng_zaehler, 3) = str_mitarbeiter Then
lng_zeile = lng_zaehler
End If
Next
Set rng_fund = .Rows(1).Find(dat_von)
If Not rng_fund Is Nothing Then
lng_spalte_von = rng_fund.Column
End If
Set rng_fund = .Rows(1).Find(dat_bis)
If Not rng_fund Is Nothing Then
lng_spalte_bis = rng_fund.Column
End If
For lng_Spalte = lng_spalte_von To lng_spalte_bis
If Weekday(.Cells(2, lng_Spalte)) > 6 And Weekday(.Cells(2, lng_Spalte)) > 7 Then
.Cells(lng_zeile, lng_Spalte) = str_kuerzel
End If
Next
End With
'Unload Me
End Sub
'Urlaub von: --> Format
Private Sub TextBox1_AfterUpdate()
TextBox1 = Format(TextBox1, "DD.MM.YYYY")
End Sub
'Urlaub bis: --> Format
Private Sub TextBox2_Afterupdate()
TextBox2 = Format(TextBox2, "DD.MM.YYYY")
End Sub
Private Sub UserForm_Initialize()
'Mitarbeiter Tabelle
With Worksheets("Personalplaner").Activate
Abwesendheit.ComboBox1.RowSource = "NZ9:NZ38"
'Kürzel laden
Abwesendheit.ListBox1.RowSource = "NS3:NT10"
End With
With ComboBox1
.ListIndex = 0
End With
End Sub
Anzeige