Möchte Übertrag aus UserForm mittels TextBox und ListBox in erste freie Zeile tätigen.
Wie bekomme ich das mit der ListBox hin, wenn ich in ControlSource kein Ziel benennen kann.
https://www.herber.de/bbs/user/49220.xls
mfg werner
Sheets(xxx).Cells(zeile, spalte) = Listbox1.Value
xxx, zeile und spalte natürlich durch die entsprechenden Werte oder Variablen ersetzen.
Gruß, Daniel
LZ = .Cells(.Rows.Count, 1).End(xlUp).Row + 1
nimm doch einfach die Variable LZ als Zeilen-Nr ebenfalls für das Rückspielen des Listboxwertes und gut ist.
Gruß, Daniel
Private Sub CommandButton1_Click()
Dim i As Integer
Dim LZ As Long
Dim vntCols As Variant
vntCols = Array(1, 2, 4, 5, 6)
With Worksheets("Tabelle1")
LZ = .Cells(.Rows.Count, 1).End(xlUp).Row + 1
For i = 1 To 5
.Cells(LZ, vntCols(i - 1)) = Controls("TextBox" & i).Value
Controls("TextBox" & i) = ""
Next i
End With
End Sub
mfg werner
Option Explicit
Private Sub CommandButton1_Click()
Dim i As Integer
Dim LZ As Long
Dim vntCols As Variant
vntCols = Array(1, 2, 4, 5, 6)
With Worksheets("Tabelle1")
LZ = .Cells(.Rows.Count, 1).End(xlUp).Row + 1
For i = 1 To 5
.Cells(LZ, vntCols(i - 1)) = Controls("TextBox" & i).Value
Controls("TextBox" & i) = ""
Next i
.Cells(LZ, 3) = ListBox1.Value
End With
End Sub