Erst mal allen ein schönes Wochenende.
Ich komme bei meinem Problem auch mit der Excelhilfe aus dem Forum nicht mehr weiter.Ich möchte in einer UserForm1 Werte über Auswahl einer ComboBox in eine ListBox einlesen und anzeigen. das klappt auch ganz gut. Nun zu meinem eigentlichen Problem: Wenn ich in der ComboBox z.B. den Wert "12-05" eingebe, erscheinen in der ListBox auch Datensätze, die den Wert "120-05" oder "1200-05" enthalten. Es sollen aber nur die Datensätze angezeigt werden, die exakt mit dem Wert in der ComboBox übereinstimmen. Also in diesem Fall nur die Datensätze, die den Wert "12-05" enthalten.
Wie müßte mein Makro abgeändert, oder ergänzt werden, damit mein Problem gelöst wird?
Private Sub ComboBox14_Change()
Dim lz As Long, i As Long, sp As Integer
Dim anz As Integer
Me.Label192.Caption = ""
Me.Label193.Caption = ""
ListBox5.Clear
ListBox6.Clear
Label180.Caption = ComboBox14.Value
With Sheets("AGH")
lz = .Range("E65536").End(xlUp).Row
For i = 3 To lz
If InStr(.Cells(i, 5).Value, ComboBox14.Value) > 0 And .Cells(i, 13).Value = "offen" Then
ListBox6.AddItem .Cells(i, 5)
anz = ListBox6.ListCount - 1
ListBox6.List(anz, 1) = .Cells(i, 2).Value 'Träger
ListBox6.List(anz, 2) = .Cells(i, 4).Value 'Träger-Nr
ListBox6.List(anz, 3) = .Cells(i, 5).Value 'Maßn-Nr
ListBox6.List(anz, 4) = .Cells(i, 6).Value 'SteA-Nr
ListBox6.List(anz, 5) = .Cells(i, 7).Value 'von
ListBox6.List(anz, 6) = .Cells(i, 8).Value 'bis
ListBox6.List(anz, 7) = .Cells(i, 14).Value 'offen
End If
Next i
End With
With Sheets("AGH")
lz = .Range("E65536").End(xlUp).Row
For i = 3 To lz
If InStr(.Cells(i, 5).Value, ComboBox14.Value) > 0 And .Cells(i, 12).Value = "Stelle besetzt" Then
ListBox5.AddItem .Cells(i, 5)
anz = ListBox5.ListCount - 1
ListBox5.List(anz, 1) = .Cells(i, 2).Value 'Träger
ListBox5.List(anz, 2) = .Cells(i, 4).Value 'Träger-Nr
ListBox5.List(anz, 3) = .Cells(i, 5).Value 'Maßn-Nr
ListBox5.List(anz, 4) = .Cells(i, 6).Value 'SteA-Nr
ListBox5.List(anz, 5) = .Cells(i, 7).Value 'von
ListBox5.List(anz, 6) = .Cells(i, 8).Value 'bis
ListBox5.List(anz, 7) = .Cells(i, 11).Value 'besetzt
End If
Next i
End With
End Sub
Private Sub ComboBox14_Click()
Me.Label192.Caption = ""
Me.Label193.Caption = ""
End Sub
Private Sub ListBox5_Click()
Me.Label181.Caption = Me.ListBox5.List(Me.ListBox5.ListIndex, 4) 'SteA-Nummer
ComboBox12.Value = Label181.Caption
Me.Label192.Caption = Me.TextBox105.Value 'Ansprechpartner
Me.Label193.Caption = Me.TextBox104.Value 'Telefon
Me.Label180.Caption = Me.TextBox103.Value 'Ort
Me.Label194.Caption = Me.TextBox106.Value 'AnforderungKurzform
CommandButton27.Enabled = False 'Schaltfläche "Kunden vormerken"
End Sub
Private Sub ListBox5_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Me.Label181.Caption = Me.ListBox5.List(Me.ListBox5.ListIndex, 4)
ComboBox12.Value = Label181.Caption
UserForm1.MultiPage1.Value = 0
CommandButton27.Enabled = False 'Schaltfläche "Kunden vormerken"
End Sub
Danke erst mal an alle Helfer
Gruß Andreas R.