ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Format a cell so that if a 7 is entered it is shown as 07:00:00 (https://www.excelbanter.com/excel-worksheet-functions/154284-format-cell-so-if-7-entered-shown-07-00-00-a.html)

Gregory OUSTED

Format a cell so that if a 7 is entered it is shown as 07:00:00
 


Peo Sjoblom

Format a cell so that if a 7 is entered it is shown as 07:00:00
 
Please post the question in the body of the message, do not post the
question in the subject line only

This is not possible using formatting



--
Regards,

Peo Sjoblom



"Gregory OUSTED" wrote in message
...




JE McGimpsey

Format a cell so that if a 7 is entered it is shown as 07:00:00
 
Not possible using formatting.

One workaround would be to use this event macro (right-click the
worksheet tab and choose view code):



Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Count 1 Then Exit Sub
If Not Intersect(.Cells, Range("B3")) Is Nothing Then
If IsNumeric(.Value) Then
On Error Resume Next
Application.EnableEvents = False
.Value = .Value / 24
Application.EnableEvents = True
On Error GoTo 0
.NumberFormat = "[hh]:mm:ss"
End If
End If
End With
End Sub

Change the cell address to suit.

In article ,
Gregory OUSTED wrote:

Harlan Grove[_2_]

Format a cell so that if a 7 is entered it is shown as 07:00:00
 
"Peo Sjoblom" wrote...
....
This is not possible using formatting


No?

A1: 7

A1's number format: 00":00:00"

Yes, this is almost certainly not what the OP wants, but it *IS* possible to
*SHOW* 07:00:00 when 7 is entered. It'll just be 7, not 7 o'clock.




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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com