VBA extract date before keywords

Heather515

New Member
Joined
Sep 11, 2021
Messages
22
Office Version
  1. 365
Platform
  1. Windows
Need help with extracting date from text strings. I need to extract the date before a keyword. Data and results are shown below. Could somebody help me to write a function or VBA macro. Thanks.
data​
result​
NoteNoteNote6/11/2010NoteNote,NoteNote9/22/2012NoteNoteTHISNoteNote,NoteNote4/5/2019NoteNote​
9/22/2012​
NoteNote5/22/2018NoteNoteTHISNoteNote,NoteNoteNote6/18/2019NoteNote,NoteNote4/18/2019NoteNote​
5/22/2018​
NoteNoteNote8/18/2018NoteNote,NoteNote4/20/2019NoteNote,NoteNote9/10/2012NoteNoteTHISNoteNote​
9/10/2012​
 
Thanks! This is what I want. It works perfect!
You're welcome. Thanks for the follow-up.

Just in case it wasn't clear, the function can be used with another keyword by using the second, optional, argument. Also, if multiple keyword matches are found, it is the first one that the function uses.
For example:

Heather515.xlsm
AB
1dataresult
2NoteNoteNote6/11/2010NoteNote,NoteNote9/22/2012NoteNoteTHISNoteNote,NoteNote4/5/2019NoteNote6/11/2010
Sheet1
Cell Formulas
RangeFormula
B2B2=GetDate(A2,"Note")
 
Upvote 0

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Forum statistics

Threads
1,215,046
Messages
6,122,855
Members
449,096
Latest member
Erald

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
Back
Top