+ Reply to Thread
Results 1 to 3 of 3

passing a time string with milliseconds into TimeValue()

  1. #1
    Registered User
    Join Date
    07-25-2008
    Location
    Tucson, AZ
    Posts
    90

    passing a time string with milliseconds into TimeValue()

    I have a CSV file that I have imported using VBA. One column contains strings containing the elapsed time (timestamp of the collected data). I will need to perform various operations using these times, so I need to convert them to valid Excel Date-formatted values. Here are the relevant parts of my code:

    Please Login or Register  to view this content.
    I am getting type-mismatch error. The problem seems to be that my time string looks like this:

    "00:00:01:21:992"
    DD:HH:MM:SS:milliseconds

    rather than this:
    "18:30:12"
    HH:MM:SS

    is there any easy way to get VBA to understand that I have "extra" columns containing the Day and Millisecond information?

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: passing a time string with milliseconds into TimeValue()

    That format is something Excel doesn't recognize as a valid data/time string. If that's how it's passed, you need to dissect it.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: passing a time string with milliseconds into TimeValue()

    Hello twd000,

    Excel time values are computed by elapsed seconds within the day. There is no built-in format to convert the time string you have to a number that Excel can understand as a time value.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

+ 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