+ Reply to Thread
Results 1 to 6 of 6

VBA to extract dates and times from text string and calculate difference

  1. #1
    Registered User
    Join Date
    05-06-2019
    Location
    denmark
    MS-Off Ver
    365 ProPlus
    Posts
    26

    VBA to extract dates and times from text string and calculate difference

    Hi Guys,

    Is it possible to make a macro that extracts a specific date and time from a text string and calculate the difference between a start date and time. Then it proceeds to loop through the string and locate the next specific date and time occurence and extract first found occurence from this one? see the data below

    Screenshot 2020-02-19 at 14.56.44.png

    So i have the column A and B where A is my starting point and B reports a list of incidents. I would like to find the time between my starting point and the first incident and then print that difference in column C. Followed by the time between incident 1 and incident 2 in column D and so forth for as many incidents as there might be. The incident report might contain random text and have different shapes but the date/time format is always the same. There is however the issue that there might be other notes in the incident report that also have a time stamp..... Like the random note in the picture. These are not to be considered. Incidents are only uniqe by their incident stamp in the end of the text string. The difference between incidents is calculated in minutes. Help would be very much appreciated, since im quite lost on how to do it

    Cross-post link https://www.mrexcel.com/board/thread.../#post-5430133
    Attached Files Attached Files
    Last edited by magge; 02-19-2020 at 11:22 AM.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Ipswich, England
    MS-Off Ver
    MS 365 Subscription Insider (Windows 11 64-bit)
    Posts
    53,275

    Re: VBA to extract dates and times from text string and calculate difference

    Administrative Note:

    We would very much like to help you with your query, however it has been brought to our attention that the same query has been posted on one or more other forums and you have not provided the required cross-post link(s) here.

    Please see Forum Rule #3 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important.

    (Note: this requirement is not optional. No help to be offered until the link is provided.)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!

    Forum Rules (updated September 2018): please read them here.
    How to use the Power Query code you've been given: help here. More about the Power suite here.
    Don't forget to say "thank you" to those who have helped you in your thread. If you wish, you can also reward them by clicking on their reputation star bottom left.

  3. #3
    Registered User
    Join Date
    05-06-2019
    Location
    denmark
    MS-Off Ver
    365 ProPlus
    Posts
    26

    Re: VBA to extract dates and times from text string and calculate difference

    Sorry about that. Here is the link

    https://www.mrexcel.com/board/thread.../#post-5430133

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    19,110

    Re: VBA to extract dates and times from text string and calculate difference

    This is how I read your problem.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    05-06-2019
    Location
    denmark
    MS-Off Ver
    365 ProPlus
    Posts
    26

    Re: VBA to extract dates and times from text string and calculate difference

    Thank you very much for the reply Jindon

    I get the following error code, when trying to run: "Run-time error '429': ActiveX component can't create object"

    Can it be because im on a Mac?

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    19,110

    Re: VBA to extract dates and times from text string and calculate difference

    Quote Originally Posted by magge View Post
    Can it be because im on a Mac?
    Correct.
    Try this one
    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)

Similar Threads

  1. Calculate difference between dates and times - display as percent elapsed
    By Sparkytech in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 02-27-2018, 08:07 PM
  2. Calculate difference between two dates and times in "days, hrs, mins
    By Rajatka in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-22-2013, 03:41 PM
  3. calculate difference between two dates and times in "days, hrs, mins, secs"
    By mankit87 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 09-03-2013, 04:27 AM
  4. [SOLVED] Date format problem using a formula in VBA to calculate difference between times and dates
    By alicebrewer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-05-2012, 03:13 AM
  5. Need to Calculate difference between 2 dates with times
    By KeithMark63 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-26-2012, 03:06 PM
  6. Replies: 2
    Last Post: 02-25-2006, 12:20 PM
  7. how do I calculate difference between two dates and times
    By PatCN in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-08-2005, 12:20 PM

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