das ist schon mein zweiter Betrag heute. Mein Projekt geht dem Ende zu und die Zeit wird knapp.
Nun zum Problem:
Mit einem Kombifeld greife ich auf zwei Spalten zu. Der ausgewählte Datensatz beider Spalten soll in mehreren Textfeldern dargestellt werden. Das funktioniert so weit. Da sich einige Datensätze wiederholen, habe ich einen Code eingebaut, der doppelte Datensätze nur einmal zeigt.
Das Ganze funktioniert nun nicht und ich hoffe auf Eure Hilfe.
Private Sub UserForm_Initialize()
Dim col As New Collection
Dim iRow As Long, ALetzte As Long
Application.EnableEvents = False
ALetzte = IIf(IsEmpty(Range("A65536")), Range("A65536").End(xlUp).Row, 65536)
On Error Resume Next
ComboBox1.Clear
ComboBox1.AddItem "Wähle die Produktnummer und Seriennummer"
For iRow = 1 To ALetzte
If Not IsEmpty(Cells(iRow, 1)) Then
col.Add Cells(iRow, 1), Cells(iRow, 1)
If Err = 0 Then
ComboBox1.AddItem Workbooks("Prüfplan.xls").Sheets("Pruefergebnisse").Cells(iRow, 1) & " _
_
Workbooks("Prüfplan.xls").Sheets("Pruefergebnisse").Cells(iRow, 2)
Else
Err.Clear
End If
End If
Next iRow
On Error GoTo 0
ComboBox1.ListIndex = 0
Application.EnableEvents = True
End Sub
Private Sub ComboBox1_Click()
If ComboBox1.ListIndex 0 Then
TextBox1 = Workbooks("Prüfplan.xls").Sheets("Pruefergebnisse").Cells(ComboBox1.ListIndex, 3) _
_
TextBox2 = Workbooks("Prüfplan.xls").Sheets("Pruefergebnisse").Cells(ComboBox1.ListIndex + _
_
1, 3)
TextBox3 = Workbooks("Prüfplan.xls").Sheets("Pruefergebnisse").Cells(ComboBox1.ListIndex, 4) _
_
Else
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
End If
End Sub