+ Reply to Thread
Results 1 to 3 of 3

Locating sections of time value using vba.

  1. #1
    Registered User
    Join Date
    04-07-2008
    Location
    Adelaide, SA
    Posts
    87

    Locating sections of time value using vba.

    Hi all,

    I have been trying to locate parts of a time value and have those parts adjusted to a suitable format.

    The problem is, the time value is written in a number of ways. These are all the possible ways they are written:

    1-09.30
    1-09.3
    1-9.30
    1-9.3

    1:09.30
    1:09.3
    1:9.30
    1:9.3

    1-09-30
    1-09-3
    1-9-30
    1-9-3

    These examples are all the same value, just written differently.

    What I am trying to achieve is for all times to end up looking like the 1st example "1-09.30". So for the example "1-9.30", I need a "0" added in front of the "9". For the example "1-9.3", I need a "0" put in front of the "9", and a "0" put after the "3".

    The seperating characters "-" "." ":" can be any combination of the 3.

    I've used this code which works for the 2nd time example, but obviously not for the 3rd and 4th examples.

    Please Login or Register  to view this content.
    hope someone can help?

    Thanks,

    Yappa
    Last edited by Yappa; 07-29-2008 at 01:13 PM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    I'd use Replace to change all possible delimiters to a common one, split the string by the delimiter, and then reassemble the string however you like.

  3. #3
    Registered User
    Join Date
    04-07-2008
    Location
    Adelaide, SA
    Posts
    87
    Thanks shg.

    You response prompted me to try a few different things. I should be on the right track now.

    Sometimes the simplest word can make a world of difference.

    Yappa

+ 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