Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default auto-insert colon when entering times

Would like to have the colon auto-insert on multiple worksheets. Hopefully
without having to write a macro.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default auto-insert colon when entering times

Need VBA event code to auto-insert.

Copy/paste this code into Thisworkbook module and it will run on all sheets
when entering a time in column A

Private Sub Workbook_SheetChange(ByVal Sh As Object, _
ByVal Target As Range)
'enter 1245p and get 12:45:00PM
If Target.Column = 1 Then
On Error GoTo endit
Application.EnableEvents = False
If Len(Target) = 4 Then
hr = Left(Target, 1)
mn = Mid(Target, 2, 2)
ap = Right(Target, 1)
Else
hr = Left(Target, 2)
mn = Mid(Target, 3, 2)
ap = Right(Target, 1)
End If
Target.Value = TimeValue(hr & ":" & mn & " " & ap)
NumberFormat = "h:mm AM/PM"
endit:
Application.EnableEvents = True
End If
End Sub


Gord Dibben MS Excel MVP

On Tue, 1 Sep 2009 14:10:04 -0700, sami
wrote:

Would like to have the colon auto-insert on multiple worksheets. Hopefully
without having to write a macro.


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
How can I insert a colon into a column of existing numbers jcmonzon Excel Discussion (Misc queries) 6 April 2nd 23 07:40 PM
Auto insert row while entering raw data mandapanda625 Excel Discussion (Misc queries) 1 July 7th 08 10:03 PM
Add colon to times meridklt New Users to Excel 4 May 11th 07 09:36 PM
Is there a way to enter times without typing a colon? dk_ Excel Discussion (Misc queries) 5 November 1st 06 08:58 PM
Insert colon in text in cell Phoenix Excel Discussion (Misc queries) 4 February 3rd 06 09:16 AM


All times are GMT +1. The time now is 05:46 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"