#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 7
Default 24 hr format

I'm still stuck. Any advise pls.. I need my cell to be formatted to
show a date and time in 24hr format eg it should show me 1-may-09
24:00 , but I keep getting it as 2-may-09 00:00 . I know its the
same but I do want it to show me as 24:00.... is this possible in
excel. thks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4
Default 24 hr format


"sorab" wrote in message
...
I'm still stuck. Any advise pls.. I need my cell to be formatted to
show a date and time in 24hr format eg it should show me 1-may-09
24:00 , but I keep getting it as 2-may-09 00:00 . I know its the
same but I do want it to show me as 24:00.... is this possible in
excel. thks in advance.


AIUI 1st May 2009 24:00 is 2nd May 2009 00:00, I don't believe that there is
such a time as 24:00! But no doubt someone with better knowledge will
correct me.

Peter


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4,393
Default 24 hr format

Not that I can think of
best wishes
--
Bernard Liengme
MVP Excel
http://people.stfx.ca

"sorab" wrote in message
...
I'm still stuck. Any advise pls.. I need my cell to be formatted to
show a date and time in 24hr format eg it should show me 1-may-09
24:00 , but I keep getting it as 2-may-09 00:00 . I know its the
same but I do want it to show me as 24:00.... is this possible in
excel. thks in advance.


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,059
Default 24 hr format

"Peter Andrews" wrote:
I don't believe that there is such a time as 24:00!


I believe that http://en.wikipedia.org/wiki/24-hour_clock is correct on this
point. In a nutshell, 24:00 is used and useful.


---- original message -----

"Peter Andrews" wrote in message
...

"sorab" wrote in message
...
I'm still stuck. Any advise pls.. I need my cell to be formatted to
show a date and time in 24hr format eg it should show me 1-may-09
24:00 , but I keep getting it as 2-may-09 00:00 . I know its the
same but I do want it to show me as 24:00.... is this possible in
excel. thks in advance.


AIUI 1st May 2009 24:00 is 2nd May 2009 00:00, I don't believe that there
is such a time as 24:00! But no doubt someone with better knowledge will
correct me.

Peter


  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,934
Default 24 hr format

You cannot do what you want with a worksheet cell format, but there is a VB
solution if your worksheet's security level allows you to make use of VB
code. Right click the tab at the bottom of the worksheet that you want to
have this functionality and select View Code from the popup menu that
appears, then copy/paste the following code into the code window that
appears...

'*************** START OF CODE ***************
Const CellsToFormat As String = "C:C,F:F"

Sub SetNumberFormat0000to2400(Optional CellAddresses As String = "")
Dim R As Range
Dim C As Range
If Len(CellAddresses) = 0 Then
Set R = Range(CellsToFormat).SpecialCells(xlCellTypeFormul as)
Else
Set R = Intersect(Range(CellsToFormat), Range(CellAddresses))
End If
If R Is Nothing Then Exit Sub
For Each C In R
If C.Value = "" Then
C.NumberFormat = "General"
ElseIf IsDate(C.Value) And CDbl(C.Value) 0 Then
If TimeValue(C.Value) = "12:00:00 AM" Then
If Int(C.Value) = 0 Then
C.NumberFormat = "24:00"
Else
C.NumberFormat = "d-mmm-yy ""24:00"""
End If
ElseIf Int(C.Value) = 0 Then
C.NumberFormat = "hh:mm"
Else
C.NumberFormat = "d-mmm-yy hh:mm"
End If
Else
C.NumberFormat = "d-mmm-yy hh:mm"
If C.Value = 0 Then C.NumberFormat = "d-mmm-yy ""24:00"""
End If
Next
End Sub

Private Sub Worksheet_Calculate()
SetNumberFormat0000to2400
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
SetNumberFormat0000to2400 Target.Address
End Sub
'*************** END OF CODE ***************

The only thing you need to do is change the range of cells I've assigned to
the CellsToFormat constant in the Const statement at the beginning of the
code to the range of cells to be covered by this "formatting" code (my
example sets the constant to Columns C and F). Now, this code will not
update constant values already in place in those columns, but it will handle
all future entries. To update all existing constants, just run this macro
one time (add it to the same code window you put the above code into and
then remove it after you have run it...

Sub Initialize0000to2400Format()
Dim C As Range
Dim R As Range
Set R = Intersect(ActiveSheet.UsedRange, Range(CellsToFormat))
For Each C In R
If Not C.HasFormula Then C.Value = C.Value
Next
End Sub

--
Rick (MVP - Excel)


"sorab" wrote in message
...
I'm still stuck. Any advise pls.. I need my cell to be formatted to
show a date and time in 24hr format eg it should show me 1-may-09
24:00 , but I keep getting it as 2-may-09 00:00 . I know its the
same but I do want it to show me as 24:00.... is this possible in
excel. thks in advance.


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
Lock Cell Format - Allow copy and paste of data without format change Chris12InKC Excel Worksheet Functions 2 May 9th 23 07:42 PM
Adding time in 24 hour format to produce hours in decimal format Hercdriver Excel Worksheet Functions 11 December 29th 09 02:06 AM
Need help with converting CUSTOM format/TEXT format to DATE format Deo Cleto Excel Worksheet Functions 6 June 2nd 09 08:14 PM
Replace million-billion number format to lakhs-crores format Sumit Excel Discussion (Misc queries) 1 December 9th 05 04:58 PM
how to format excel format to text format with separator "|" in s. azlan New Users to Excel 1 January 31st 05 12:57 PM


All times are GMT +1. The time now is 04:07 AM.

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"