Ich habe zwei verschiedene Listboxen.
jetzt soll über ein Button die ausgewählten Werte der einen ListboxA in die andere ListboxB übertragen werden.
Dazu werden in ListboxB noch weitere Werte eingeschrieben, die berechnet werden.
Mit dem folgendem Sub werden die Daten der ListboxA ausgewählt und einer Variablen zugewiesen.
Private Sub ListBox_material_artikelauswahl_change()
On Error Resume Next
Bestellspalte1 = ListBox_material_artikelauswahl.List(ListBox_material_artikelauswahl.ListIndex, _
0)
On Error Resume Next
Bestellspalte2 = ListBox_material_artikelauswahl.List(ListBox_material_artikelauswahl.ListIndex, _
1)
On Error Resume Next
Bestellspalte3 = ListBox_material_artikelauswahl.List(ListBox_material_artikelauswahl.ListIndex, _
2)
On Error Resume Next
Bestellspalte5 = ListBox_material_artikelauswahl.List(ListBox_material_artikelauswahl.ListIndex, _
3)
On Error Resume Next
Bestellspalte6 = ListBox_material_artikelauswahl.List(ListBox_material_artikelauswahl.ListIndex, _
4)
On Error Resume Next
Bestellspalte11 = ListBox_material_artikelauswahl.List(ListBox_material_artikelauswahl. _
ListIndex, 6)
On Error Resume Next
usrBestellung.txt_bestellung_sp8.Value = _
WorksheetFunction.VLookup(Bestellspalte11, Tabelle17.Range("a1:b18"), 2, False)
On Error Resume Next
Bestellspalte10 = ListBox_material_artikelauswahl.List(ListBox_material_artikelauswahl. _
ListIndex, 5)
End Sub
Das klappt auch super den alle Wert habe ich mit msgbox anzeigen lassen und überprüft. jede Variable ist also der korrekte wert zugewiesen.
Dann werden über einen zweiten Button die wert übertragen, dass passiert mit folgendem Sub
Anmerkung: die fehlenden variablen werden aus Textfeldern bezogen und sind auch korrekt
Private Sub cbutton_material_ubertragen_Click()
'liste wird mit den Variablen gefüllt
With usrBestellung.ListBox_material_Bestelldetail
.ColumnCount = 12
.ColumnWidths = "1,5cm;2cm;1,6cm;2cm;2,3cm;1,5cm;2cm;2cm;2cm;2cm;1cm;1cm"
ListBox_material_Bestelldetail.AddItem
ListBox_material_Bestelldetail.List(ListBox_material_Bestelldetail.ListCount - 1, 0) = _
Bestellspalte1
ListBox_material_Bestelldetail.List(ListBox_material_Bestelldetail.ListCount - 1, 1) = _
Bestellspalte2
ListBox_material_Bestelldetail.List(ListBox_material_Bestelldetail.ListCount - 1, 2) = _
Bestellspalte3
ListBox_material_Bestelldetail.List(ListBox_material_Bestelldetail.ListCount - 1, 3) = _
Bestellspalte4
ListBox_material_Bestelldetail.List(ListBox_material_Bestelldetail.ListCount - 1, 4) = _
Bestellspalte5
ListBox_material_Bestelldetail.List(ListBox_material_Bestelldetail.ListCount - 1, 5) = _
Bestellspalte6
ListBox_material_Bestelldetail.List(ListBox_material_Bestelldetail.ListCount - 1, 6) = _
Bestellspalte7
ListBox_material_Bestelldetail.List(ListBox_material_Bestelldetail.ListCount - 1, 7) = _
Bestellspalte8
ListBox_material_Bestelldetail.List(ListBox_material_Bestelldetail.ListCount - 1, 8) = _
Bestellspalte9
ListBox_material_Bestelldetail.List(ListBox_material_Bestelldetail.ListCount - 1, 9) = _
Bestellspalte10
'--> Fehler :ListBox_material_Bestelldetail.List(ListBox_material_Bestelldetail.ListCount - 1, _
10) = Bestellspalte11
End With
MsgBox (Bestellspalte11 & Chr(13) & Bestellspalte10 & Chr(13) & Bestellspalte9 & Chr(13) & _
Bestellspalte8 & Chr(13) & Bestellspalte7 & Chr(13) & Bestellspalte6 & Chr(13) & Bestellspalte5 & Chr(13) & Bestellspalte4 & Chr(13) & Bestellspalte3 & Chr(13) & Bestellspalte2 & Chr(13) & Bestellspalte1)
End Sub
->>> Fehler: genau hier ist der Fehler sobald ich die überstehende Zeile aktiviere, wird mir ein Fehler _
ausgegeben, die Variable ist aber belegt es steht ein Wert in Bestellspalte11 drin
Kann es sein, dass die Listfunktion nur bis 10 Spalten aufnimmt?
Wie kan ich das Problem dann lösen?
Ich frage mich eben nur, warum die Funktion mit ...ListCount - 1, 10) nicht funktioniert und würde mich über eine Erklärung sehr freuen.
Danke
danke Mario