AW: UF TextBoxen füllen
27.09.2010 10:14:31
Dirk
Hallo Heinz,
hier mal ein Ansatz.
da in der bereitgestellten Tabelle die Eintraege nicht die Informationen bezueglich Ueberstunden etc enthalten wird auch nur das Ausgewertet, was in der Tabelle vorhanden ist. Fuer alle Felder, welche leer bleiben wird "Nicht Besetzt" eingetragen.
Das Feld Gesamt wird auch nicht befuellt, da Du nicht mitgeteilt hast, was dort hinein soll.
Kopiere bitte die Makros in den bereich Userform2.
Du musst in der Userform auch noch Textbox19 und Textbox20 tauschen, da sonst die Daten falsch eingetragen sind.
Private Sub ComboBox1_Change()
If ComboBox2.Value "" And ComboBox1.Value "" Then
Call Loesche_Form
Call Fuelle_Form
End If
End Sub
Private Sub ComboBox2_Change()
If ComboBox1.Value "" And ComboBox2.Value "" Then
Call Loesche_Form
Call Fuelle_Form
End If
End Sub
Private Sub UserForm_Initialize()
Set sh = ActiveSheet
For Each v In sh.Range("C1:AG1")
On Error GoTo skip_Error
If v "" Then
ComboBox1.AddItem v
End If
skip_Error:
On Error GoTo 0
Next
Set sh = ActiveSheet
For Each v In sh.Range("BF3:BF5")
If v "" Then
ComboBox2.AddItem v
End If
Next
End Sub
Private Sub Fuelle_Form()
Dim SuchSpalte As Long, i As Long, j As Long, k As Long, l As Long
Dim ci As Long
Application.EnableEvents = False
j = 1
k = 1
l = 1
SuchSpalte = ComboBox1.ListIndex + 3 'listindex startet mit 0!!
'suche Vorarbeiter
For i = 3 To 154
If Len(Trim(Cells(i, SuchSpalte).Value)) = 2 And Mid(Cells(i, SuchSpalte), 1, 1) = 1 Then
'hier die Vorarbeiter
Debug.Print Cells(i, SuchSpalte)
If Right(Cells(i, SuchSpalte), 1) = ComboBox2.Value Then
TextBox3.Value = Cells(i, 1).Value
End If
ElseIf Cells(i, SuchSpalte).Value = "S" And Right(Cells(i, 2).Value, 1) = ComboBox2.Value _
Then
TextBox19.Value = Cells(i, 1).Value
ElseIf Trim(Cells(i, SuchSpalte).Value) = ComboBox2.Value And j 0 Then
If UserForm2.Controls.Item(ci).Value = "" Then
UserForm2.Controls.Item(ci).Value = "Nicht Besetzt"
End If
End If
Next ci
Application.EnableEvents = True
End Sub
Private Sub Loesche_Form()
Dim ci As Long
Application.EnableEvents = False
For ci = 0 To UserForm2.Controls.Count - 1
If InStr(1, UserForm2.Controls.Item(ci).Name, "TextBox") 0 Then
UserForm2.Controls.Item(ci).Value = ""
End If
Next ci
Application.EnableEvents = True
End Sub
Lass' hoeren, ob ok.
Gruss
Dirk aus Dubai