einen schönen guten Morgen.
Ich habe ein kleines Problem und bitte euch um eure Hilfe.
Die Listbox in UF lade ich wie folgt:
Worksheets("ScantabelleKopierer1Ber").Activate
'Anfang Listbox1
Dim i As Long
ListBox1.Clear
ListBox1.ColumnCount = 7
ListBox1.ColumnWidths = "1,0cm;0,8cm;1,5cm;3,5cm;1,5cm;1,5cm;1,5cm"
Dim Zeile As Long
With Worksheets("ScantabelleKopierer1Ber")
' Zeile = .Cells(.Rows.Count, 1).End(xlUp).Row
Zeile = .Cells(.Rows.Count, 6).End(xlUp).Row
With Me.ListBox1
' For i = 2 To 87
For i = 2 To Zeile
.AddItem Cells(i, 1) 'SpalteA in erste Spalte
.List(.ListCount - 1, 2) = Cells(i, 2) 'SpalteB in zweite Spalte
.List(.ListCount - 1, 3) = Cells(i, 3) 'SpalteC in dritte Spalte
.List(.ListCount - 1, 4) = Cells(i, 4) 'SpalteD in vierte Spalte
.List(.ListCount - 1, 5) = Cells(i, 5) 'SpalteD in fünfte Spalte
.List(.ListCount - 1, 6) = Cells(i, 6) 'SpalteD in sechste Spalte
Next
End With
End With
Me.TextBox1 = "5056i"
'Ende Listbox1
Die Auswahl aus der Listbox erfolgt mit nachstehendem Code:
Private Sub ListBox1_Click()
If Me.Tag = "1" Then Exit Sub
'klick = ListBox1.ListIndex
With ListBox1
Me.TextBox1 = .List(.ListIndex, 0)
'If ListBox1.List(ListBox1.ListIndex, 1) = "" Then
' Me.TextBox2 = "5056i"
'Else
Me.TextBox2 = .List(.ListIndex, 2)
'End If
Me.TextBox3 = .List(.ListIndex, 3)
Me.TextBox4 = .List(.ListIndex, 4)
Me.TextBox5 = .List(.ListIndex, 5)
Me.TextBox6 = .List(.ListIndex, 6)
' Me.TextBox6 = .List(.ListIndex, 6)
End With
ListBox2.ListIndex = ListBox1.ListIndex
End Sub
Nun möchte ich um einen weiteren Datensatz einzufügen, die erste Zeile auswählen,
in welche in Spalte A kein Wert ist jedoch in Spalte E = 6 sich aufgrund von Formeln
eine 0 befindet.
Im Forum habe ich einen Suchcode gefunden, welcher den vorgegebenen Wert sucht und dabei die letzte Zeile mit diesem Wert auswählt, aber ich möchte ja die nächste Zeile
ohne diesen Wert.
Dim iRow As Integer
For iRow = 0 To ListBox1.ListCount - 1
If ListBox1.List(iRow, 0) = TextBox1.Text Then
ListBox1.Selected(iRow) = True
End If
Next iRow
Was muss ich ändern oder machen, damit das gelingt?
Besten Dank für eure Hilfe.
Gruss
Peter