LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
Lee Hunter
 
Posts: n/a
Default Input mask for active cell

I am attempting to set up an input mask for the active cell such that the
time can be entered as 3 or 4 digits without the full colon.(815 for 08:15
AM)

In the sample code below, I never get to the numberformat property and the
code sems to be recursively called from itself. I've tried both the
Calculate and the Change events. What's my best solution?
Thanks!
Lee

Private Sub Worksheet_Some_event(ByVal Target As Range
Dim InTime As String
Dim Apostrophe As String
Apostrophe = ""
If Len(Target) = 4 Then ' Allow 815 instead of 0815
InTime = Apostrophe & Left(Target.Value, 2) & ":" & Right(Target.Value, 2) &
Apostrophe
Else: InTime = Apostrophe & "0" & Left(Target.Value, 1) & ":" &
Right(Target.Value, 2) & Apostrophe
End If
ActiveCell.Value = InTime
ActiveCell.NumberFormat = "hh:mm A"
End Sub

 
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
Help - Can't directly input Japanese characters into cell NKK Excel Discussion (Misc queries) 0 January 3rd 06 02:00 AM
Delete cell contents with input to adjacent cell Ashley Frank Excel Discussion (Misc queries) 1 October 5th 05 04:28 PM
How do I change the format of a cell based on what I input? Husker87 Excel Worksheet Functions 8 August 19th 05 10:45 PM
cell color index comparison MINAL ZUNKE New Users to Excel 1 June 30th 05 07:11 AM
what is the format for an input cell? Pumaman Excel Discussion (Misc queries) 2 February 8th 05 05:05 AM


All times are GMT +1. The time now is 10:28 AM.

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

About Us

"It's about Microsoft Excel"