+ Reply to Thread
Results 1 to 3 of 3

Format Method - how do I stop a cell turning into a date?

  1. #1
    Forum Contributor
    Join Date
    04-27-2006
    Location
    Cayman Islands
    Posts
    379

    Format Method - how do I stop a cell turning into a date?

    Right, sorry this is probably a simple one but I can't do it... I have information in a variable that is "1-4" the variable is defined as a String but whenever I use the following code excel turns it into a date.

    Please Login or Register  to view this content.
    I tried this... amoungst other things...

    Please Login or Register  to view this content.
    Can't seem to get anything to work, bugging the hell outta me! Appreciate any tips.

    EDIT:
    Additionally I need a custom number format that works like 0.##, i.e. displays up to 2 decimal places, but I don't want the decimal point visible if the zeroes aren't present - i.e. that currently displays "1" as "1."
    Last edited by ChrisMattock; 12-10-2008 at 09:26 AM. Reason: Additional question...

  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good evening ChrisMattock
    Quote Originally Posted by ChrisMattock View Post
    Right, sorry this is probably a simple one but I can't do it... I have information in a variable that is "1-4" the variable is defined as a String but whenever I use the following code excel turns it into a date.
    Hmmmm, sure is a pesky problem. The Format function doesn't always do a sterling job in forcing a cells number format - especially if Excel has other ideas

    You could try forcing the cell format, then post the number to it, thus :
    Please Login or Register  to view this content.
    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  3. #3
    Forum Contributor
    Join Date
    04-27-2006
    Location
    Cayman Islands
    Posts
    379
    Wow, I really thought that this would be a simple problem to solve! Obviously not, eventually after much furrowing of the brow I cam up with this, which works but I guess isn't ideal!

    Please Login or Register  to view this content.

    Sadly the below still aren't formatting as they should, I shall try the method you have provided.

    Please Login or Register  to view this content.
    EDIT:

    Thanks Dominicb - problem solved in it's entirety! +rep for you (if I can!)
    Last edited by ChrisMattock; 12-10-2008 at 09:26 AM. Reason: Solved

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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