Time Format

P

paul

Hi

how do i set a format to read time. I want to enter say 18
and Excel to recognise that i mean 6pm. I don't want it to
reference any particular date.

I want t oenter say 2 times 18.30 and 9.00 and be able to
work out the differnce in hours

Any help appreciated
thanks
Paul
 
D

David McRitchie

Hi Paul,
Formats are for display purposes, except that it also tells what kind
of number you have. So if you have a time format it is assumed
you are entering a time and you have to enter hours:minutes
The minimum you would have t o enter is 18:
with the colon after the 18.

You could probably use an Event macro as long as you remain under
24 hours *and* after 1 AM. If you need midnight to 1AM you
will have to remove cange the condition test in the following code..

To install Right Click on the worksheet tab you want to use in
view code, plop the following code inside.

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
if target.column <> 3 then exit sub 'only for Column C
Application.EnableEvents = False 'should be part of Change macro
If Target.Value > 1 Then Target.Value = Time(Target.Value, 0)
Application.EnableEvents = True 'should be part of Change macro
End Sub

More information on Events
http://www.mvps.org/dmcritchie/excel/event.htm

Some examples for nonstandard Date and Time Entry -- Chip Pearson
http://www.cpearson.com/excel/datetimeentry.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

count blank cells to next value 7
adding days and times 3
How do I set up Excel to display time as typed 1
to find diffrence in time 3
Filter by Time 1
Time Format 2
time shift and salary calculation 1
Times 2

Top