Live-Forum - Die aktuellen Beiträge
Datum
Titel
28.03.2024 21:12:36
28.03.2024 18:31:49
Anzeige
Archiv - Navigation
804to808
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
804to808
804to808
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Datum von Userform in Tabelle / erneut!
04.10.2006 21:23:00
Userform
Hallo allerseits,
ich bin es nochmal mit der Übertragung eines Datums von einer Textbox in die Tabelle.
Mir ist ja miterlweile (Dank @all) bekannt, dass dafür:
CDate(Me.Textbox1)
nötig ist. Das habe ich in einem anderen Form auch soweit ganz gut hinbekommen
Aber bei folgendem Code weiß ich nicht, wo ich was ändern muss, sodas der Inhalt aus Box 5 und 6 eben als Datum in die Tabelle eingetragen wird.
Option Explicit

Private Sub ComboBox1_Click()
If ComboBox1.ListIndex <> 0 Then
TextBox1 = Cells(ComboBox1.ListIndex + 1, 1)
TextBox2 = Cells(ComboBox1.ListIndex + 1, 2)
TextBox3 = Cells(ComboBox1.ListIndex + 1, 3)
ComboBox2 = Cells(ComboBox1.ListIndex + 1, 4)
TextBox5 = Cells(ComboBox1.ListIndex + 1, 5)
TextBox6 = Cells(ComboBox1.ListIndex + 1, 6)
Else
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
ComboBox2 = "Normal"
TextBox5 = ""
TextBox6 = ""
End If
End Sub


Private Sub CommandButton1_Click()
' Fragt nach, ob Datensatz wirklich gelöscht werden soll
If MsgBox("Datensatz wirklich löschen?", vbQuestion + vbYesNo, _
" Datensatz löschen") = vbNo Then Exit Sub
If ComboBox1.ListIndex > 0 Then
Rows(ComboBox1.ListIndex + 1).Delete
UserForm_Initialize
End If
End Sub


Private Sub CommandButton2_Click()
'Prüft, ob in Textfeld 5 ein Datum
If IsDate(TextBox5) = False Then
MsgBox "Fehler: Datumsformat fehlerhaft."
Exit Sub
End If
'Prüft, ob in Textfeld 6 ein Datum
If IsDate(TextBox5) = False Then
MsgBox "Fehler: Datumsformat fehlerhaft."
Exit Sub
End If
Dim xZeile As Long
'Prüft, ob Textbox 1 nicht leer
If TextBox1 = "" Then
MsgBox "Dienstgrad eingeben"
Exit Sub
End If
'Prüft, ob Textbox 2 nicht leer
If TextBox2 = "" Then
MsgBox "Name eingeben"
Exit Sub
End If
If ComboBox1.ListIndex = 0 Then
xZeile = [A65536].End(xlUp).Row + 1
Else
xZeile = ComboBox1.ListIndex + 1
End If
Cells(xZeile, 1) = TextBox1
Cells(xZeile, 2) = TextBox2
Cells(xZeile, 3) = TextBox3
Cells(xZeile, 4) = ComboBox2
Cells(xZeile, 5) = TextBox5
Cells(xZeile, 6) = TextBox6
'Sortieren
Columns("A:F").Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
UserForm_Initialize
End Sub


Private Sub CommandButton3_Click()
'Beendet das Userform
Unload Me
End Sub


Private Sub UserForm_Initialize()
'Inhalt der ComboBox2
With ComboBox2
.AddItem "Normal"
.AddItem "Langzeit"
End With
Dim aRow As Long, i As Long
Application.EnableEvents = False
ComboBox1.Clear
aRow = [A65536].End(xlUp).Row
ComboBox1.AddItem "neuen Datensatz hinzufügen"
For i = 2 To aRow
ComboBox1.AddItem Cells(i, 1) & " " & Cells(i, 2) & ", " & Cells(i, 5) & " - " & Cells(i, 6) & " [" & Cells(i, 3) & "]"
Next i
ComboBox1.ListIndex = 0
Application.EnableEvents = True
End Sub

?
Gruss
Bernd
:-(

2
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Datum von Userform in Tabelle / erneut!
04.10.2006 21:37:25
Userform
Hallo Bernd,
wenn ich das richtig sehe, hast du dir deine Frage schon selbst beantwortet. An der Stelle, wo du die Zuordnungen machst
Cells(xZeile, 5) = TextBox5
Cells(xZeile, 6) = TextBox6
muss genau die Funktion stehen. Dann sollte es klappen.
By the way:
'Prüft, ob in Textfeld 6 ein Datum
If IsDate(TextBox5) = False Then
MsgBox "Fehler: Datumsformat fehlerhaft."
Exit Sub
End If
Das prüft, ob in TextBox5 ein Datum steht und nicht wie gewollt in Textfeld 6... ;-)
Martin
AW: Datum von Userform in Tabelle / erneut!
04.10.2006 21:58:02
Userform
Danke, funzt perfekt.
PS: Gilt auch Textfeld-Prüfung 6 ;-)
Anzeige

302 Forumthreads zu ähnlichen Themen

Anzeige
Anzeige
Anzeige

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige