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
Solved

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

Posted on 2011-09-15
12
256 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:Ingeborg Hawighorst
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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 50

Expert Comment

by:Ingeborg Hawighorst
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:Ingeborg Hawighorst
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
 
LVL 50

Accepted Solution

by:
Ingeborg Hawighorst 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:Ingeborg Hawighorst
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

839 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