Consulting

Results 1 to 5 of 5

Thread: Solved: Date/time format change with macro...

  1. #1
    VBAX Regular
    Joined
    Oct 2007
    Posts
    76
    Location

    Solved: Date/time format change with macro...

    Hi, Folks...

    I'm trying to populate a schedule by taking specific information from another spreadsheet.

    This is no problem, but where I'm stumped is that I'm trying to take date information from the source worksheet, which is in this format:

    8/7/2007 8:00:00 AM

    and put it into the target location as

    8/7/2007

    I have a feeling that "mid" won't work, due to the fact that the number of characters in the date changes from the mimimum above, to something like:

    12/12/2007

    and everything in between...

    So, I'm guessing I can do a format change to the date, to make it date only, instead of date/time, but I'm not sure how to do that.

    Any ideas?? Thanks so much in advance for any help!!

  2. #2
    range("A1").value = datevalue(your value)
    range("A1").numberformat = "d/m/yyyy"
    2+2=9 ... (My Arithmetic Is Mental)

  3. #3
    VBAX Regular
    Joined
    Oct 2007
    Posts
    76
    Location
    Thanks!! I can work with that... Cheers!

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    If those cells are real date/time cells, you can use INT as the date is the integer portion of the number value.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    It isn't clear to me what the format of your data is, but here's two ideas assumming the value is in cell A1:
    If the input value is text, like 12/12/2007 8:30 PM, then use
    =LEFT(A1, SEARCH(" ", A1))
    If the input is in "date" format, then use
    =INT(A1)

Posting Permissions

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