wie man am nachfolgendem Code sehen kann, bin ich noch am üben.
Der Code soll 4 Listboxen auslesen und die Werte in Tabelle "Liste" schreiben.
Kann mir jemand behilflich sein bei der Richtigstellung meines Codes.
Private Sub cmd_Daten_an_Liste_Click()
Dim n1 As Long
Dim p1 As Long
With ThisWorkbook.Worksheets("Liste")
.Range("A3:K12").ClearContents
If CBool(ListBox1.ListCount > 0) Then
For n1 = 0 To ListBox1.ListCount - 1
For p1 = 0 To ListBox1.ColumnCount - 1
.Cells(n1 + 3, p1 + 1).Value = CStr(ListBox1.List(n1, p1))
Next p1
Next n1
End If
End With
Dim n2 As Long
Dim p2 As Long
With ThisWorkbook.Worksheets("Liste")
.Range("A16:M25").ClearContents
If CBool(ListBox2.ListCount > 0) Then
For n2 = 0 To ListBox2.ListCount - 1
For p2 = 0 To ListBox2.ColumnCount - 1
.Cells(n2 + 16, p2 + 1).Value = CStr(ListBox2.List(n2, p2))
Next p2
Next n2
End If
End With
Dim n3 As Long
Dim p3 As Long
With ThisWorkbook.Worksheets("Liste")
.Range("A29:J40").ClearContents
If CBool(ListBox3.ListCount > 0) Then
For n3 = 0 To ListBox3.ListCount - 1
For p3 = 0 To ListBox3.ColumnCount - 1
.Cells(n3 + 29, p3 + 1).Value = CStr(ListBox3.List(n3, p3))
Next p3
Next n3
End If
End With
Dim n4 As Long
Dim p4 As Long
With ThisWorkbook.Worksheets("Liste")
.Range("A44:Q54").ClearContents
If CBool(ListBox4.ListCount > 0) Then
For n4 = 0 To ListBox4.ListCount - 1
For p4 = 0 To ListBox4.ColumnCount - 1
.Cells(n4 + 44, p4 + 1).Value = CStr(ListBox4.List(n4, p4))
Next p4
Next n4
End If
End With
End Sub
Vielen Dank schon mal im Voraus!
Gruß
Bernd