Anzeige
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Format: Datum Zeit-Zeit

Forumthread: Format: Datum Zeit-Zeit

Format: Datum Zeit-Zeit
16.02.2003 13:43:55
Mario
Gibt es eine Möglichkeit z.B. die Eingabe 16.2.03.13.40.13.50 so auszugeben: 16.02.2003 13:40-13:50
Da ich viele Eingaben in dieser Form machen muss würde mir diese Formatierung die Eingabe sehr erleichtern und verschnellern.


Anzeige

5
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
Re: Format: Datum Zeit-Zeit
16.02.2003 14:09:24
M@x

Hallo Mario,
gib einfach 16020313401350 Manate, Tage Stunden Minuten immer zweistellig und formatiere ##"."##".""20"##* ##":"##"-"##":"##


Gruss

M@x

Re: Format: Datum Zeit-Zeit
16.02.2003 14:11:14
udo


Hi, damit kommst schon mal weiter, in Bezug auf vereinfachtes Eingeben der Uhr zeit Bsp. 1200 wird zu 12:00 , und Datum könntest ja die Nachbarzelle entsprechend formartieren.


Private Sub Worksheet_Change(ByVal Target As Range)

Dim sTxt As String
If Target.Column < 5 Or Target.Column > 21 Then Exit Sub
If IsEmpty(Target) Or Selection.Cells.Count > 1 Then Exit Sub
sTxt = CStr(Target.Value)
Select Case Len(sTxt)
Case 3: sTxt = "0" & sTxt & "00"
Case 4: sTxt = sTxt & "00"
Case 5: sTxt = "0" & sTxt
End Select
sTxt = Left(sTxt, 2) & ":" & Mid(sTxt, 3, 2) & ":" & Right(sTxt, 2)
On Error GoTo ERRORHANDLER
Application.EnableEvents = False
Target.Value = TimeValue(sTxt)
Application.EnableEvents = True
Exit Sub
ERRORHANDLER:
ActiveCell.ClearContents
Application.EnableEvents = True

End Sub

Anzeige
Re: Format: Datum Zeit-Zeit
16.02.2003 14:11:15
udo


Hi, damit kommst schon mal weiter, in Bezug auf vereinfachtes Eingeben der Uhr zeit Bsp. 1200 wird zu 12:00 , und Datum könntest ja die Nachbarzelle entsprechend formartieren.


Private Sub Worksheet_Change(ByVal Target As Range)

Dim sTxt As String
If Target.Column < 5 Or Target.Column > 21 Then Exit Sub
If IsEmpty(Target) Or Selection.Cells.Count > 1 Then Exit Sub
sTxt = CStr(Target.Value)
Select Case Len(sTxt)
Case 3: sTxt = "0" & sTxt & "00"
Case 4: sTxt = sTxt & "00"
Case 5: sTxt = "0" & sTxt
End Select
sTxt = Left(sTxt, 2) & ":" & Mid(sTxt, 3, 2) & ":" & Right(sTxt, 2)
On Error GoTo ERRORHANDLER
Application.EnableEvents = False
Target.Value = TimeValue(sTxt)
Application.EnableEvents = True
Exit Sub
ERRORHANDLER:
ActiveCell.ClearContents
Application.EnableEvents = True

End Sub

Anzeige
Re: Format: Datum Zeit-Zeit
16.02.2003 14:11:22
udo


Hi, damit kommst schon mal weiter, in Bezug auf vereinfachtes Eingeben der Uhr zeit Bsp. 1200 wird zu 12:00 , und Datum könntest ja die Nachbarzelle entsprechend formartieren.


Private Sub Worksheet_Change(ByVal Target As Range)

Dim sTxt As String
If Target.Column < 5 Or Target.Column > 21 Then Exit Sub
If IsEmpty(Target) Or Selection.Cells.Count > 1 Then Exit Sub
sTxt = CStr(Target.Value)
Select Case Len(sTxt)
Case 3: sTxt = "0" & sTxt & "00"
Case 4: sTxt = sTxt & "00"
Case 5: sTxt = "0" & sTxt
End Select
sTxt = Left(sTxt, 2) & ":" & Mid(sTxt, 3, 2) & ":" & Right(sTxt, 2)
On Error GoTo ERRORHANDLER
Application.EnableEvents = False
Target.Value = TimeValue(sTxt)
Application.EnableEvents = True
Exit Sub
ERRORHANDLER:
ActiveCell.ClearContents
Application.EnableEvents = True

End Sub

Anzeige
Danke für die Antworten
16.02.2003 15:08:21
Mario

Danke für eure schnellen Antworten. Ich habe die Lösung mit der Formatierung gewählt, weil ich mich mit Makros nicht auskenne.

;

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige