View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Héctor Miguel Héctor Miguel is offline
external usenet poster
 
Posts: 434
Default Take a 3 or for digit time and convet it to time in one cell

hi, !

I'm trying to take just one cell and set it up to display a time.
it someone entered 330 I need the cell to display 3:30.
When no time is entered in it can display 0:00 for the time.
I have tried clicking on time in the number drop down.
It shows 0:00 then I type in 930. when I hit enter it returns 0:00.
If I click on the ceel it displays a date and time.
All I want in the cell is the time to show if it is entered 930...


assuming you don't need to do this on the whole cells of your worksheet -?-
(i.e.) for only cells in range [B2:B5] copy/paste/type/... the following lines
in "that" worksheet code module:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Intersect(Target, Range("b2:b5")) Is Nothing Then GoTo DoNothing
Application.EnableEvents = False
Target(1) = Format(Target(1), "0:00")
DoNothing:
Application.EnableEvents = True
End Sub

hth,
hector.