Solved

excel 2007 how to change cell format h:mm to h.mm

Posted on 2011-09-15
12
252 Views
Last Modified: 2012-06-21
Via Excel 2007 under 'Format cell format > Custom' I want to use the 'period' (fullstop) instead of the colon. This is because to input a colon into a cell one needs to press 'Shift' then colon, whereas a 'period' (fullstop) doesn't require 'Shift', and thus allows for quicker & easier input.

If I cannot change this format code, then I figure I would need to remap my keyboard keys.

Your thoughts would be appreciated please.
0
Comment
Question by:kazmdav
  • 6
  • 5
12 Comments
 
LVL 50

Expert Comment

by:teylyn
ID: 36547302
Hello,

the cell format is for displaying the value, not for entering.

If you want to ENTER a time value with a different format, then you need to change your system settings for the time format. This will affect all applications on your system, though.

cheers, teylyn
0
 

Author Comment

by:kazmdav
ID: 36547315
Thank you Teylyn. I have now changed my system settings & will test things out later today.
0
 
LVL 2

Expert Comment

by:jan24
ID: 36549429
Good solution, teylyn.  If you want to only affect Excel, then you could instead leave your time settings as they are, and instead use a macro that catches the WorsheetChange event and converts decimal values to times.  If that sounds like a useful solution then let me know and I'd happily write that macro for you.
0
 
LVL 50

Expert Comment

by:teylyn
ID: 36552352
kazmday, jan24's suggestion would be good if you only need this behaviour in specific range of a spreadsheet.

I've recently written a VBA macro for a team who work under immense time pressure. They need to enter a date/time value and can't be slowed down by entering all the characters. So now they enter a number in 24 hr format and a + or - sign to indicate a day ahead or in the past, e.g.

15.00+ returns 3 pm tomorrow
7.00 returns 7 am today
0.30- returns 12:30 am yesterday

This only affects specific areas of the spreadsheet. In other cells, they can enter 15.30 as a number and it stays a number.

If that is something you are interested in, I'll dig it up.

cheers, teylyn
0
 

Author Comment

by:kazmdav
ID: 36552527
Thank you for both ideas. I had to confer with the end users, thus my delay.

Teylyn, your idea brought to light a requirement that they sometimes need to deal with, which is, calculating to / from number of hours (at a site visit) that spans across 1 day.

Therefore, I'd appreciate if you could dig up that macro please, because I think your macro will be a good start for me to work with.

I have a little VBA experience & will aim to modify it to calculate hours across a day and remove 'tomorrow' & 'today' text. If I need help I'll come back to the forum.

Regards, kazmdav
0
 
LVL 50

Expert Comment

by:teylyn
ID: 36552663
Hello,

I'll dig up that macro, and modify it for publication, but in the meantime:

If you subtract one date/time value from another and the result is more than one day, then you can format the result with square brackets around the hour portion to show values greater than 24.

For example:

<Sept-13-2011 3pm> - <Sept-12-2011 8am>

The result is one day and 7 hours, or 31 hours. If that is formatted as a regular time value, you'd see only

7:00

If you format it with the custom format

[hh]:mm

it will be displayed as

31:00

The underlying value is the same, i.e. the number 1.291666667

cheers, teylyn
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 50

Accepted Solution

by:
teylyn earned 500 total points
ID: 36552749
See the attached file for the macro I mention above.  

The values are actually entered as 900 or 2230, i.e. without a decimal point.

Hope you can do something with that.

cheers, teylyn
Simplified-Date-Time-entry.xlsm
0
 

Author Comment

by:kazmdav
ID: 36555177
Thank you Teylyn. I'll work on it & respond with how I go. Much appreciate your responses.
0
 

Author Comment

by:kazmdav
ID: 36577354
Hi Teylyn, I've been delayed due to catching a bug.... as soon as I recover I will get onto this. I will keep this question updated.
0
 

Author Comment

by:kazmdav
ID: 36937303
I'll be back on deck & will work on this on Tuesday 11 Oct.  It was quite a nasty bug and I thank you for your patience.

Regards, Kazmdav
0
 
LVL 50

Expert Comment

by:teylyn
ID: 36937630
Thanks for the heads up, Kazmdav. Glad to see you're back on deck.
0
 

Author Comment

by:kazmdav
ID: 36953678
Thank you. Your code worked like a charm Teylyn.

Apart from just changing the target range, I only needed to change the display format of the cells to just "h:mm AM/PM".  To do this I added one simple line of code in the 'Worksheet_Change' procedure; as indicated in attached code excerpt.

It might seem strange not to display the actual date in the cell, but its what the user wanted & he's happy!
' return target cell to general format
    Target.NumberFormat = "General"
    Target = TimeEntry(iTarget)
    Target.NumberFormat = "h:mm AM/PM"   < I added this line

Open in new window

0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Dealing with unintended Excel Active-X resizing quirks (VBA code simulates "self correction") David Miller (dlmille) Intro Not everyone is a fan of Active-X controls in spreadsheets (as opposed to the UserForm approach, the older Form controls …
Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now