AW: UserForm Kalender
18.09.2011 15:48:46
Hajo_Zi
Hallo Ingo,
laut Deinem Code wird der letzte Eintrag in Spalte A überschrieben. Ich hätte Loletzte +1 benutzt.
Fast ales wird als Text eingetragen.
Der Code ist doch bestimmt in der Userform, da kann der Bezug zur UserForm entfallen.
Ich hätte es so geschrieben auf der Grundlage Deines Codes.
Option Explicit
Private Sub CommandButton1_Click()
Dim Loletzte As Long
Set frm = UserForm1
With Sheets("Erfassung")
'letzte belegte Zelle in Tabelle finden
Loletzte = IIf(IsEmpty(.Cells(.Rows.Count, 1)), _
.Cells(Rows.Count, 1).End(xlUp).Row, .Rows.Count)
.Cells(Loletzte, 1) = frm.TextBox1.Value
.Cells(Loletzte, 1).Offset(0, 1) = frm.TextBox2.Value
.Cells(Loletzte, 1).Offset(0, 2) = frm.ComboBox1.Value
.Cells(Loletzte, 1).Offset(0, 3) = frm.TextBox4.Value
.Cells(Loletzte, 1).Offset(0, 4) = frm.TextBox5.Value
.Cells(Loletzte, 1).Offset(0, 5) = frm.ComboBox2.Value
.Cells(Loletzte, 1).Offset(0, 6) = frm.TextBox7.Value
'Optionsfelder auswerten
If OptionButton1.Value = True Then
.Cells(Loletzte, 1).Offset(0, 7) = 1
Else
If OptionButton2.Value = True Then
.Cells(Loletzte, 1).Offset(0, 8) = 1
Else
If OptionButton3.Value = True Then
.Cells(Loletzte, 1).Offset(0, 9) = 1
End If
End If
End If
If OptionButton4.Value = True Then
.Cells(Loletzte, 1).Offset(0, 10) = 1
Else
If OptionButton5.Value = True Then
.Cells(Loletzte, 1).Offset(0, 11) = 1
Else
If OptionButton6.Value = True Then
.Cells(Loletzte, 1).Offset(0, 12) = 1
End If
End If
End If
End With
Set frm = Nothing
End Sub
Gruß Hajo