AW: Werte aus textbox/Combobox in tabelle eintragen
22.03.2010 09:20:39
Tino
Hallo,
könnte so funktionieren.
Tabelle im Code anpassen.
Auf der Userform ist eine ComboBox1, eine TextBox1 und ein CommandButton1.
Private Sub FuelleCombo()
Dim strErsteAdresse$, rngZelle As Range
With Tabelle1
Set rngZelle = .Rows(1).Find(What:="Datum", After:=.Cells(1, .Columns.Count), LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Not rngZelle Is Nothing Then
strErsteAdresse = rngZelle.Address
Do
If rngZelle.Offset(0, 1) <> "" Then _
ComboBox1.AddItem rngZelle.Offset(0, 1)
ComboBox1.List(ComboBox1.ListCount - 1, 1) = rngZelle.Column
Set rngZelle = .Rows(1).FindNext(rngZelle)
Loop While rngZelle.Address <> strErsteAdresse
End If
End With
End Sub
Private Sub CommandButton1_Click()
Dim LRow&, LCol&
If Not IsNumeric(TextBox1) Then
MsgBox "Geben Sie eine Zahl ein"
Exit Sub
End If
If ComboBox1.ListIndex = -1 Then
MsgBox "Wählen Sie eine Wahrengruppe"
Exit Sub
End If
With Tabelle1
LCol = ComboBox1.List(, 1)
LRow = .Cells(.Rows.Count, LCol).End(xlUp).Row + 1
.Cells(LRow, LCol) = Date
.Cells(LRow, LCol + 2) = TextBox1 * 1
End With
ComboBox1.ListIndex = -1
TextBox1 = ""
MsgBox "Daten wurden gebucht"
End Sub
Private Sub UserForm_Initialize()
FuelleCombo
End Sub
Gruß Tino