Private Sub Button_Fertig_Click()
Unload Personal
End Sub
Private Sub ComboBox1_Enter()
ComboBox1.BackColor = vbYellow
End Sub
Private Sub ComboBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
ComboBox1.BackColor = vbWhite
End Sub
Private Sub ComboBox2_Enter()
ComboBox2.BackColor = vbYellow
End Sub
Private Sub ComboBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean)
ComboBox2.BackColor = vbWhite
Dim rngZelle As Range
'Hier soll jetzt eigentlich in dem Tabellenblatt "Data" nach bereits vorhandenen Einträgen gesucht werden
'Diese stehen in Spalte "K" also eigentlich in .Columns(11) und diese Spalte ist aufgebaut wie die TextBox3
'Nun wird mir aber jedes mal gesagt, dass die eingegebenen Daten neu sind, auch wenn sie in der Liste stehen
'Zusätzlich habe ich die dumpfe Ahnung, dass durch rngZelle.Offset(0, 2) die Zellen nach dem gefundenen Eintrag genommen werden
'und nicht ab dem Beginn der gefundenen Zeile
With Sheets("Data")
Set rngZelle = .Columns(11).Find(TextBox3, lookat:=xlWhole)
If Not rngZelle Is Nothing Then
TextBox4 = rngZelle.Offset(0, 2) 'Personalnummer
TextBox5 = rngZelle.Offset(0, 6) 'Kostenstelle
TextBox6 = rngZelle.Offset(0, 7) 'Kostenstellen Name
TextBox7 = rngZelle.Offset(0, 8) 'Zuständig
Else
MsgBox "Der/die Mitarbeiter/in ist neu"
End If
End With
Set rngZelle = Nothing
End Sub
Private Sub ComboBox3_Enter()
ComboBox3.BackColor = vbYellow
End Sub
Private Sub ComboBox3_Exit(ByVal Cancel As MSForms.ReturnBoolean)
ComboBox3.BackColor = vbWhite
End Sub
Private Sub ComboBox4_Enter()
ComboBox4.BackColor = vbYellow
End Sub
Private Sub ComboBox4_Exit(ByVal Cancel As MSForms.ReturnBoolean)
ComboBox4.BackColor = vbWhite
End Sub
Private Sub ComboBox1_Change() 'Nachname
TextBox3.Value = ComboBox1.Value & " , " & ComboBox2
End Sub
Private Sub ComboBox2_Change() 'Vorname
TextBox3.Value = ComboBox1.Value & " , " & ComboBox2
End Sub
Private Sub Button_Take_Click()
Dim last As Integer
last = ActiveSheet.Cells(Rows.Count, 2).End(xlUp).Row + 1
ActiveSheet.Cells(last, 4).Value = Personal.ComboBox2.Value
ActiveSheet.Cells(last, 5).Value = Personal.ComboBox1.Value
ActiveSheet.Cells(last, 10).Value = Personal.ComboBox3.Value
ActiveSheet.Cells(last, 13).Value = Personal.ComboBox4.Value
'Unload Personal
End Sub
Private Sub UserForm_Initialize()
Personal.Height = 400
Personal.Width = 320
Personal.ComboBox1.RowSource = "Data!C:C" 'Nachname
Personal.ComboBox2.RowSource = "Data!D:D" 'Vorname
Personal.ComboBox3.RowSource = "Tabelle1!C2:C3" 'Personalklasse
Personal.ComboBox4.RowSource = "Tabelle1!B:B" 'Funktion
End Sub