ist es möglich, einen neuen Punkt in die Listbox zu schreiben und diesen direkt auszuwählen? Genaue Erklärung und Details im angehangenen Bild.
https://www.herber.de/bbs/user/157695.png
https://www.herber.de/bbs/user/157804.xlsm
Gruß Marcus
Private Sub WertHintenRan()
Dim arrNr
Dim r&, i&, j&
With ListBox1
.AddItem
.List(.ListCount - 1, 1) = TextBox1
End With
With TabFürListe
.ListRows.Add
r = .ListRows.Count
.DataBodyRange.Columns(1).Cells(.DataBodyRange.Columns(1).Cells.Count) = ListBox1.List(ListBox1.ListCount - 1, 0)
.DataBodyRange.Columns(2).Cells(.DataBodyRange.Columns(1).Cells.Count) = ListBox1.List(ListBox1.ListCount - 1, 1)
With .DataBodyRange
.Cells(r, 1) = .Cells(1, 1)
.Cells(r, 2) = TextBox1
ListBox1.List = .Value
End With
End With
ReDim Preserve arrSelected(UBound(arrSelected) + 1)
arrSelected(UBound(arrSelected)) = ListBox1.ListCount - 1
TextBox1 = ""
For i = 0 To ListBox1.ListCount - 1
For j = 0 To UBound(arrSelected)
If arrSelected(j) = i Then
ListBox1.Selected(i) = True
Exit For
End If
Next j
Next i
End Sub
Gruß
ReDim arrSelected(UBound(arrSelected) + 1)
arrSelected(UBound(arrSelected)) = ListBox1.ListCount - 1
Gruß
Private Sub CommandButton2_Click()
Dim i&, j&
For i = 0 To ListBox1.ListCount - 1
If i > iZeile Then
If ListBox1.Selected(i) Then
ReDim Preserve arrSelected(j)
arrSelected(j) = i
j = j + 1
End If
End If
Next i
If MsgBox("Soll der Wert zusätzlich in die Listbox eingefügt werden", _
vbQuestion + vbYesNo, "Abfrage wie in Listbox übernehmen") = vbYes Then
WertHintenRan
Else
WertAendern
End If
End Sub
In WertHintenRan das Preserve wieder rein.