+ Reply to Thread
Results 1 to 5 of 5

Stop Excel changing cell format?

  1. #1
    Registered User
    Join Date
    03-17-2011
    Location
    hong kong
    MS-Off Ver
    Excel 2003
    Posts
    13

    Stop Excel changing cell format?

    I have a spreadsheet collecting measurements plus a date and time stamp. For ease of data entry some users want to enter a time string as "h.mm" with a dot rather than the more usual colon "h:hh".

    I have a validation macro that scans the cell value and replaces any '.' with ':'.
    Please Login or Register  to view this content.
    This works, and the macro completes OK.

    BUT - as the replace is done Excel changes the format of the cell from 'General' to Custom "h:mm". This means that the next time a value is entered it is converted behind the scenes to a date/time value. e.g "9.35" is converted to a number representing "09 01 1900 8:24:00 AM" which messes up all sorts of things.

    Is there any way to stop Excel from changing the cell format?

    And for bonus points : Can anyone point me to some code that validates and reformats entered time strings? I'm sure I'm not the first person to want to extract something like "21:35" from variants of 21.35, 9.35pm, 21:35PM etc..

    Thanks!

  2. #2
    Forum Contributor
    Join Date
    01-02-2007
    Location
    Australia NSW
    MS-Off Ver
    2013
    Posts
    494

    Re: Stop Excel changing cell format?

    I think you are better to force theusers to enter teh time in the set format instead of trying to convert an incorrect format after the event.

  3. #3
    Registered User
    Join Date
    03-17-2011
    Location
    hong kong
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Stop Excel changing cell format?

    "better to force theusers to enter teh time in the set format"

    You are probably correct, but this is a specific request to allow them to enter times using a '.'

    It's simpler to do with one finger using only the numeric pad while standing up and holding stuff in your other hand. Real world problem...

    Anyone else able to help?

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Stop Excel changing cell format?

    An easy method would be to have two cells; the entry cell and result time cell .

    This converts the EnterTime cell value and put the result in the cell to the right
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    03-17-2011
    Location
    hong kong
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Stop Excel changing cell format?

    Thanks for the reply. Your solution would work, as would having separate cells for hour and minute so they just press enter to move from one to the other.

    What I have done for now is just reset the cell format as soon as Excel 'fixes' it...
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1