VBA to extraxt dates and times from text string and calculate differences

magges

New Member
Joined
Jul 1, 2019
Messages
11
Office Version
  1. 365
Platform
  1. MacOS
Hi Guys,

Is it possible to make a macro that extracts the last occurence of a 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 second last date and time occurence and extract the last occurence from this one? see the data below

Screenshot 2020-02-19 at 13.32.04.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 (the last occurence in the text string) 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. The difference between incidents is calculated in minutes. Help would be very much appreciated :)
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

magges

New Member
Joined
Jul 1, 2019
Messages
11
Office Version
  1. 365
Platform
  1. MacOS
So it just got more difficult. There can also be random notes in the incident report as seen on the picture.. these also have a timestamp.. The only uniqe thing to the incidents is that they are always ended by "incident x".
 

Attachments

  • Screenshot 2020-02-19 at 14.56.44.png
    Screenshot 2020-02-19 at 14.56.44.png
    103.6 KB · Views: 5

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
65,618
Office Version
  1. 365
Platform
  1. Windows
Cross posted VBA to extract dates and times from text string and calculate difference

While we do allow Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules). This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 

Forum statistics

Threads
1,147,571
Messages
5,741,895
Members
423,693
Latest member
Excelquestion35

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top