AW: Problem mit Eingabemaske
02.09.2007 11:54:00
Matthias
Hallo
Ich habe nun noch einmal etwas genauer geschaut und habe festgestellt, das beim Klick auf
den Submit-Button die Zellen nur als Text übergeben werden
Ich meine z.B. diese Code-Zeile: Cells(xZeile, 1) = TextBox8
Das muss aber zwingend ein Datum sein!
Das solltest Du ändern in: Cells(xZeile, 1) = CDate(TextBox8)
(sonst wird übrigens ein neu eingetragener Wert auch nicht mit sortiert!)
Gib also generell bei der Übergabe der Textboxen in die Zellen den Type mit, damit die Ausrichtung in den Zellen nicht plötzlich links(weil Text) steht.
Also hier nochmal geändert:
Private Sub CommandButton2_Click()
Dim xZeile As Long
If TextBox1 = "" Then Exit Sub
If ComboBox1.ListIndex = 0 Then
xZeile = [D65536].End(xlUp).Row + 1
Else
xZeile = ComboBox1.ListIndex + 1
End If
Cells(xZeile, 4) = CCur(TextBox1)
Cells(xZeile, 5) = CCur(TextBox2)
Cells(xZeile, 6) = CCur(TextBox3)
Cells(xZeile, 7) = CCur(TextBox4)
Cells(xZeile, 8) = CCur(TextBox5)
Cells(xZeile, 9) = CCur(TextBox6)
Cells(xZeile, 10) = CCur(TextBox7)
Cells(xZeile, 1) = CDate(TextBox8)
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
TextBox4 = ""
TextBox5 = ""
TextBox6 = ""
TextBox7 = ""
TextBox8 = ""
Columns("A:I").Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
UserForm_Initialize
End Sub
Um die Textbox10 (Last Entry)
mit dem Inhalt der letzten gefüllten Zelle aus Spalte A zu füllen,
habe ich die fett markierte Zeile hinzugefügt
Private Sub UserForm_Initialize()
Dim aRow, i As Long
TextBox10 = Cells(Cells(Rows.Count, 1).End(xlUp).Row, 1)
Application.EnableEvents = False
ComboBox1.Clear
aRow = [D65536].End(xlUp).Row
ComboBox1.AddItem "choose Date"
For i = 2 To aRow
ComboBox1.AddItem Cells(i, 1)
Next i
ComboBox1.ListIndex = 0
Application.EnableEvents = True
End Sub
In der Hoffnung geholfen zu habe ...