Live-Forum - Die aktuellen Beiträge
Anzeige
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Formate werden gelöscht

Forumthread: Formate werden gelöscht

Formate werden gelöscht
15.11.2006 17:35:06
Achille
Hallo Leute,
helft mir bitte,
habe eine Eingabemaske.
Die Datumseingabe erfolgt über eine Combobox, die weiteren Dateneingaben erfolgen durch manuelle Eingabe in die vorgesehen Textbox.
Nach übernahmen der Einträge erscheinen die Daten korrekt in die vorgesehenen Spalten.
Problem ist: Die Datumsformate sind Gelöscht und sind nur als numerische Zahlen erkennbar.
Meine Frage an die Profis „wo liegt bitte der Fehler“
Danke im Voraus Gruß Achi
****************************************************************************************
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)
TextBox4 = Cells(ComboBox1.ListIndex + 1, 4)
TextBox5 = Cells(ComboBox1.ListIndex + 1, 5)
Else
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
TextBox4 = ""
TextBox5 = ""
End If
End Sub


Private Sub CommandButton1_Click()
If ComboBox1.ListIndex > 0 Then
Rows(ComboBox1.ListIndex + 1).Delete
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
TextBox4 = ""
TextBox5 = ""
UserForm_Initialize
End If
End Sub


Private Sub CommandButton2_Click()
Dim xZeile As Long
If TextBox1 = "" Then Exit Sub
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) = TextBox4
Cells(xZeile, 5) = TextBox5
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
TextBox4 = ""
TextBox5 = ""
End Sub


Private Sub CommandButton3_Click()
Unload Me
End Sub


Private Sub UserForm_Initialize()
Dim aRow, i As Long
Application.EnableEvents = False
ComboBox1.Clear
aRow = [A65536].End(xlUp).Row
ComboBox1.AddItem "  "
For i = 2 To aRow
ComboBox1.AddItem Cells(i, 1) & ", " & Cells(i, 2)
Next i
ComboBox1.ListIndex = 0
Application.EnableEvents = True
End Sub

Anzeige

6
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Formate werden gelöscht
15.11.2006 18:08:59
Peter
Hallo Achille,
aus TextBoxes erhälst du, wie es der Name sagt nur Text.
Du kannst aber mit Cells(xZeile, 1).Value = Format(TextBox1.Value, "dd.mm.yyyy") arbeiten
Du kannst, um ganz sicher zu sein, dass es sich um Datums handelt abfragen
If IsNumeric(TextBox1.Value) And IsDate(TextBox1.Value) Then
Cells(xZeile, 1).Value = Format(CDate(TextBox1.Value), "dd.mm.yyyy")
End If
verwenden.
Viele Grüße Peter
Eine kurze Nachricht, ob es läuft, wäre nett - danke.
Anzeige
AW: Formate werden gelöscht
15.11.2006 18:34:40
Achille
Vielen Dank für die schnelle Hilfe, leider weis ich nicht wo ich die werte eintragen soll.
Ich habe es war probiert, doch bekam ich andauernd Fehlermeldungen.
Ich nerve ziemlich, doch es Wäre sehr nett wenn Ihr mir die Werte an der richtigen Stelle eintragen würdet.
Danke nochmals
Gruss Achi
Anzeige
AW: Formate werden gelöscht
15.11.2006 20:21:18
Peter
Hallo Achi,
ich würde mich speziell um das eine Makro kümmern; versuch es also einmal so:

Private Sub CommandButton2_Click()
Dim xZeile As Long
If TextBox1 = "" Then Exit Sub
If ComboBox1.ListIndex = 0 Then
xZeile = [A65536].End(xlUp).Row + 1
Else
xZeile = ComboBox1.ListIndex + 1
End If
Cells(xZeile, 1) = Format(CDate(TextBox1.Text), "dd.mm.yyyy")
Cells(xZeile, 2) = Format(CDate(TextBox2.Text), "dd.mm.yyyy")
Cells(xZeile, 3) = Format(CDate(TextBox3.Text), "dd.mm.yyyy")
Cells(xZeile, 4) = Format(CDate(TextBox4.Text), "dd.mm.yyyy")
Cells(xZeile, 5) = Format(CDate(TextBox5.Text), "dd.mm.yyyy")
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
TextBox4 = ""
TextBox5 = ""
End Sub

Viele Grüße Peter
Eine kurze Nachricht, ob es läuft, wäre nett - danke.
Anzeige
AW: Formate werden gelöscht
15.11.2006 20:40:45
Peter
Hallo Achi,
ich glaube die besten Ergebnisse bringt folgende Makro-Schreibweise:

Private Sub CommandButton2_Click()
Dim xZeile As Long
If TextBox1 = "" Then Exit Sub
If ComboBox1.ListIndex = 0 Then
xZeile = [A65536].End(xlUp).Row + 1
Else
xZeile = ComboBox1.ListIndex + 1
End If
Cells(xZeile, 1).Value = CDate(TextBox1.Text)
Cells(xZeile, 2).Value = CDate(TextBox2.Text)
Cells(xZeile, 3).Value = CDate(TextBox3.Text)
Cells(xZeile, 4).Value = CDate(TextBox4.Text)
Cells(xZeile, 5).Value = CDate(TextBox5.Text)
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
TextBox4 = ""
TextBox5 = ""
End Sub

Viele Grüße Peter
Eine kurze Nachricht, ob es läuft, wäre nett - danke.
Anzeige
AW: Formate werden gelöscht
16.11.2006 10:30:28
Achille
Peter! du bist einfach klasse,
hat alles wunderbar geklappt.
Vielen vielen Dank, hast mir sehr geholfen
schönen Gruß
Achille
;

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Entdecke mehr
Finde genau, was du suchst

Die erweiterte Suchfunktion hilft dir, gezielt die besten Antworten zu finden

Suche nach den besten Antworten
Unsere beliebtesten Threads

Entdecke unsere meistgeklickten Beiträge in der Google Suche

Top 100 Threads jetzt ansehen
Anzeige