Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Brian Handly
 
Posts: n/a
Default Time Entries: Want to Skip the ":"

I have a time sheet with Start and Stop times. I want to enter 22:00 as
"2200". However, EXCEL does not recognize "2200" as a time. How can I
force it to recognize it as a time or how can I convert it to a time?

Texas Handly
  #2   Report Post  
Posted to microsoft.public.excel.misc
Gord Dibben
 
Posts: n/a
Default Time Entries: Want to Skip the ":"

Brian

See Chip Peason's site for date/time "quick entry" methods.

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


Gord Dibben Excel MVP

On Sun, 18 Dec 2005 12:00:22 -0600, Brian Handly wrote:

I have a time sheet with Start and Stop times. I want to enter 22:00 as
"2200". However, EXCEL does not recognize "2200" as a time. How can I
force it to recognize it as a time or how can I convert it to a time?

Texas Handly

  #3   Report Post  
Member
 
Location: London
Posts: 78
Default

Here's a little routine I've just written which I think will solve your problem.

Paste this into the 'ThisWorkbook' module of your workbook.
Replace GT with the Greater Than symbol and LT with the Less Than symbol.

Note that the routine will only operate on cells formatted as 'Date', so you can choose which cells get the treatment and which ones don't.

Code:============================================= ======

Public xLastRange As Excel.Range

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Excel.Range)
If Not IsEmpty(xLastRange) And TypeName(xLastRange) GT LT "Nothing" Then
If xLastRange.Cells.Count = 1 Then
If InStr(1, xLastRange.NumberFormat, ":") GT 0 Then
If Format(xLastRange.Value, "hh:mm") LT GT xLastRange.Text Then
tTimeAsDigits = Format(xLastRange.Value, "0000")
tTimeAsValue = Left(tTimeAsDigits, 2) & ":" & Mid(tTimeAsDigits, 3, 2) & ":00"
If IsDate(tTimeAsValue) Then
dTimeAsValue = TimeValue(tTimeAsValue)
xLastRange.Value = dTimeAsValue
Else
xLastRange.Value = "#TIME?"
Beep
MsgBox ("Invalid time entered. Please re-enter.")
End If
End If
End If
End If
End If

Set xLastRange = Target
End Sub




Hope this helps.
Regards,
BizMark
  #4   Report Post  
Posted to microsoft.public.excel.misc
Brian Handly
 
Posts: n/a
Default Time Entries: Want to Skip the ":"

BizMark wrote:
Here's a little routine I've just written which I think will solve your
problem.

Paste this into the 'ThisWorkbook' module of your workbook.
Replace GT with the Greater Than symbol and LT with the Less Than
symbol.

Note that the routine will only operate on cells formatted as 'Date',
so you can choose which cells get the treatment and which ones don't.

Code:============================================= ======

Public xLastRange As Excel.Range

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal
Target As Excel.Range)
If Not IsEmpty(xLastRange) And TypeName(xLastRange) GT LT "Nothing"
Then
If xLastRange.Cells.Count = 1 Then
If InStr(1, xLastRange.NumberFormat, ":") GT 0 Then
If Format(xLastRange.Value, "hh:mm") LT GT
xLastRange.Text Then
tTimeAsDigits = Format(xLastRange.Value, "0000")
tTimeAsValue = Left(tTimeAsDigits, 2) & ":" &
Mid(tTimeAsDigits, 3, 2) & ":00"
If IsDate(tTimeAsValue) Then
dTimeAsValue = TimeValue(tTimeAsValue)
xLastRange.Value = dTimeAsValue
Else
xLastRange.Value = "#TIME?"
Beep
MsgBox ("Invalid time entered. Please
re-enter.")
End If
End If
End If
End If
End If

Set xLastRange = Target
End Sub




Hope this helps.
Regards,
BizMark


Thanks
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
Entering Times Denise Excel Discussion (Misc queries) 9 November 15th 05 04:57 PM
Time sheets Driver Excel Worksheet Functions 5 November 7th 05 11:19 AM
Formula for a time card skateblade Excel Worksheet Functions 6 November 2nd 05 09:28 PM
Adding time damezumari Excel Discussion (Misc queries) 2 June 20th 05 08:35 PM
Time Sheet Calculation Help Needed! sax30 Excel Worksheet Functions 2 April 26th 05 08:08 PM


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