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

Posted on 2011-09-15
Medium Priority
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.
Question by:kazmdav
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
LVL 50
ID: 36547302

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

Author Comment

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

Expert Comment

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.

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

LVL 50
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

Author Comment

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
LVL 50
ID: 36552663

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


If you format it with the custom format


it will be displayed as


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

cheers, teylyn
LVL 50

Accepted Solution

Ingeborg Hawighorst (Microsoft MVP / EE MVE) earned 2000 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

Author Comment

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

Author Comment

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.

Author Comment

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
LVL 50
ID: 36937630
Thanks for the heads up, Kazmdav. Glad to see you're back on deck.

Author Comment

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


Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This article describes a serious pitfall that can happen when deleting shapes using VBA.
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

649 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