Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Time formatting

Hi

Does anyone have a method for entering any number, say, 0800 and it will
automatically insert a colon in between the 08 and 00. I have a method of
automatically changing data entered in lower case to upper case, but cannot
work this one out - Can you?

--
Kind Regards

Mick


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Time formatting

See


http://cpearson.com/excel/DateTimeEntry.htm


In article ,
"Mick Southam" wrote:

Does anyone have a method for entering any number, say, 0800 and it will
automatically insert a colon in between the 08 and 00. I have a method of
automatically changing data entered in lower case to upper case, but cannot
work this one out - Can you?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default Time formatting

Hi,

Put this in your Worksheet Code Module:


Private Sub Worksheet_Change(ByVal Target As Range)

Application.EnableEvents = False
If Application.Intersect(Range("B2:B100"), Target) _
Is Nothing Then GoTo e:

With Target
If .Cells.Count 1 Then GoTo e:
If Not IsNumeric(.Value) Then GoTo e:
If .HasFormula Then GoTo e:
If .Value Like "[!0123456789]" Then GoTo e:

Select Case Len(.Value)
Case 1: .Value = "00:0" & .Value
Case 2: .Value = "00:" & .Value
Case 3, 4: .Value = Left(.Value, 1) & ":" & Right(.Value, 2)
Case Else: .ClearContents
End Select

If .Value = 1 Then .ClearContents
.NumberFormatLocal = "HH:MM"

End With

e:
Application.EnableEvents = True

End Sub


--
Regards,
Soo Cheon Jheong
_ _
^ąŻ^
--


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Time formatting MD Excel Worksheet Functions 3 June 28th 07 11:49 PM
Time formatting Eileen New Users to Excel 2 October 3rd 05 09:34 PM
Time formatting dziw Excel Discussion (Misc queries) 2 September 15th 05 01:30 PM
time formatting and time categorizing (vlookup or data validation) MarianneR Excel Worksheet Functions 4 November 18th 04 03:24 PM
time formatting and time categorizing (vlookup or data validation) MarianneR Excel Worksheet Functions 0 November 18th 04 03:13 PM


All times are GMT +1. The time now is 09:33 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"