ich fülle eine Listbox mit Array. Dann möchte ich die Textbox entweder mit Text oder mit Datum oder mit Währung, oder mit einer Formel füllen und dann den jeweiligen Wert in die Tabelle übernehmen.
Die Listbox fülle ich mit folgendem Code:
Private Sub UserForm_Initialize()
Application.ScreenUpdating = False 'flackern abschalten
ListBox1.ColumnCount = 14
ListBox1.ColumnWidths = "1cm;1cm;1cm;1cm;1cm;1,5cm;1cm;2cm;4cm;2cm;2cm;2cm;2cm"
arrWerte = Sheets("Tabelle4").[A1:N54]
ListBox1.List = arrWerte
Application.ScreenUpdating = True
End Sub
Die Daten von der Listbox in die Textboxes übernehme ich mit folgendem Code:Private Sub ListBox1_Click()
If ListBox1.Tag "" Then Exit Sub
TextBox1 = ListBox1.List(ListBox1.ListIndex, 0)
TextBox2 = ListBox1.List(ListBox1.ListIndex, 1)
TextBox3 = ListBox1.List(ListBox1.ListIndex, 2)
TextBox4 = ListBox1.List(ListBox1.ListIndex, 3)
TextBox5 = ListBox1.List(ListBox1.ListIndex, 4)
TextBox6 = ListBox1.List(ListBox1.ListIndex, 5)
TextBox7 = ListBox1.List(ListBox1.ListIndex, 6)
TextBox8 = ListBox1.List(ListBox1.ListIndex, 7)
TextBox9 = ListBox1.List(ListBox1.ListIndex, 8)
TextBox10 = ListBox1.List(ListBox1.ListIndex, 9)
TextBox11 = ListBox1.List(ListBox1.ListIndex, 10)
TextBox12 = ListBox1.List(ListBox1.ListIndex, 11)
TextBox13 = ListBox1.List(ListBox1.ListIndex, 12)
TextBox14 = ListBox1.List(ListBox1.ListIndex, 13)
End Sub
Das Zurückschreiben von Textbox in Tabelle erfolgt mit folgendem Code:Private Sub CommandButton1_Click()
Dim WB As Workbook 'benötigt für akuelle Workbook
Dim WS1 As Worksheet 'benötigt für Kontodaten
Set WB = ThisWorkbook 'benötigt für Combobox2 Kontoart und Combobox1 _
Kontodaten
Set WS1 = WB.Sheets("Tabelle4") 'benötigt für Combobox1 Kontodaten
Dim xZeile As Long
If TextBox1 = "" Then Exit Sub
If ListBox1.ListIndex = 0 Then
xZeile = [a65536].End(xlUp).Row + 1
Else
xZeile = ListBox1.ListIndex + 1
End If
'WS1.Cells(xZeile, 1) = TextBox1
WS1.Cells(xZeile, 2) = TextBox2
WS1.Cells(xZeile, 3) = TextBox3
WS1.Cells(xZeile, 4) = TextBox4
WS1.Cells(xZeile, 5) = TextBox5
WS1.Cells(xZeile, 6) = TextBox6
WS1.Cells(xZeile, 7) = TextBox7
WS1.Cells(xZeile, 8) = TextBox8
WS1.Cells(xZeile, 9) = TextBox9
WS1.Cells(xZeile, 10) = TextBox10
WS1.Cells(xZeile, 11) = TextBox11
WS1.Cells(xZeile, 12) = TextBox12
WS1.Cells(xZeile, 13) = TextBox13
WS1.Cells(xZeile, 14) = TextBox14
'Auswahl löschen
TextBox1.Value = ""
TextBox2.Value = ""
TextBox3.Value = ""
TextBox4.Value = ""
TextBox5.Value = ""
TextBox6.Value = ""
TextBox7.Value = ""
TextBox8.Value = ""
TextBox9.Value = ""
TextBox10.Value = ""
TextBox11.Value = ""
TextBox12.Value = ""
TextBox13.Value = ""
TextBox14.Value = ""
UserForm_Initialize
End Sub
Was muss ich bitte ändern, damit die richtigen Werte in die Tabelle übernommen werden und muss ich bei der Eingabe in die Textbox irgendwelche Eingabevorgaben berücksichtigen? z. B. Format-Währung, Format-Datum ect.Besten Dank für eure Hilfe.
Gruss
Peter