How do I extract multiple date values from variable text string?

WanttobeExcelNinja

New Member
Joined
Jan 13, 2015
Messages
8
How do I extract the date values separately from the variable text strings below? I learned how to extract the numbers only from these cells with the following array Ron (Mr. Excel) posted on youtube:

=SUM(MID(0&M14,LARGE(ISNUMBER(--MID(M14,ROW(INDIRECT("1:"&LEN(M14))),1))*ROW(INDIRECT("1:"&LEN(M14))),ROW(INDIRECT("1:"&LEN(M14))))+1,1)*10^(ROW(INDIRECT("1:"&LEN(M14)))-1))

I was trying to find a way to create these date values from the numbers only string the above formula created but could not figure out.

I also tried different formulas to just pull the first date in one cell and pull the second date in a second cell but was running into problems with the variable nature users input this information. I could spend time slicing the data with text to columns and reformatting but I was hoping to discover a formula that would workaround most entry differences. The goal would be to rerun scripts each month and only add new data and have little work reformatting for entry differences.

Any help, suggestions, guidance is much appreciated.


[TABLE="width: 651"]
<tbody>[TR]
[TD]Linedescription[/TD]
[TD]Mr. Excel Numbers only formula[/TD]
[/TR]
[TR]
[TD]Water Escrows 1/1/2015-1/31/15[/TD]
[TD="align: right"]11201513115[/TD]
[/TR]
[TR]
[TD]BROCHI- 2014 Water Escrow Catch-up 1/1/14-8/31/14[/TD]
[TD="align: right"]2014111483114[/TD]
[/TR]
[TR]
[TD]Water Usage 3/31/14 - 6/30/14[/TD]
[TD="align: right"]3311463014[/TD]
[/TR]
[TR]
[TD]Water Usage 09/12/14 - 10/14/14[/TD]
[TD="align: right"]91214101414[/TD]
[/TR]
[TR]
[TD]Water Usage -4/28/14-5/28/14[/TD]
[TD="align: right"]4281452814[/TD]
[/TR]
[TR]
[TD]Water Usage 4/30/14-5/30/14[/TD]
[TD="align: right"]4301453014[/TD]
[/TR]
[TR]
[TD]Water True-up 4/30/14 - 6/30/14[/TD]
[TD="align: right"]4301463014[/TD]
[/TR]
[TR]
[TD]Water True-up 6/30/14-9/2/14[/TD]
[TD="align: right"]630149214[/TD]
[/TR]
[TR]
[TD]Water Usage (07/11/14-08/06/14)[/TD]
[TD="align: right"]71114080614[/TD]
[/TR]
[TR]
[TD]Water Usage 5/23/14-6/25/14[/TD]
[TD="align: right"]5231462514[/TD]
[/TR]
[TR]
[TD]Water Usage 09/11/14-10/10/14[/TD]
[TD="align: right"]91114101014[/TD]
[/TR]
</tbody>[/TABLE]


Kind Regards,

WanttobeexcelNinja
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Messy because the data is so inconsistent but it works:

First Date:
=SUBSTITUTE(SUBSTITUTE(TRIM(LEFT(RIGHT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A2," - "," ")," "," ")," "," "),"-"," ")," ",REPT(" ",255)),510),255)),"(",""),")","")

Second Date:
=SUBSTITUTE(SUBSTITUTE(TRIM(RIGHT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A2," - "," ")," "," ")," "," "),"-"," ")," ",REPT(" ",255)),255)),"(",""),")","")
 
Upvote 0
<b>Worksheet Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: #FFFFFF;border-collapse: collapse; border-color: #BBB"><thead><tr style=" background-color: #DAE7F5;color: #161120"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: #DAE7F5;color: #161120">B1</th><td style="text-align:left">=ExtractDate(<font color="Blue">$A1,COLUMNS(<font color="Red">$B1:B1</font>)</font>)</td></tr></tbody></table></td></tr></table><br />


UDF to ADD:
Code:
Function ExtractDate(S As String, MatchNumber As Integer) As String
Static RegExp As Object


If RegExp Is Nothing Then
    Set RegExp = CreateObject("vbscript.regexp")
    RegExp.Pattern = "(\d?\d/){2}\d{2,4}"
    RegExp.Global = True
End If


ExtractDate = RegExp.Execute(S).Item(MatchNumber - 1).Value
End Function

RESULTS:


Excel 2013
ABC
1Water Escrows 1/1/2015-1/31/151/1/20151/31/15
2BROCHI- 2014 Water Escrow Catch-up 1/1/14-8/31/141/1/148/31/14
3Water Usage 3/31/14 - 6/30/143/31/146/30/14
4Water Usage 09/12/14 - 10/14/1409/12/1410/14/14
5Water Usage -4/28/14-5/28/144/28/145/28/14
6Water Usage 4/30/14-5/30/144/30/145/30/14
7Water True-up 4/30/14 - 6/30/144/30/146/30/14
8Water True-up 6/30/14-9/2/146/30/149/2/14
9Water Usage (07/11/14-08/06/14)07/11/1408/06/14
10Water Usage 5/23/14-6/25/145/23/146/25/14
11Water Usage 09/11/14-10/10/1409/11/1410/10/14
Sheet1
 
Upvote 0
Here's how I did it..

First Date
=TRIM(MID(TRIM(SUBSTITUTE(A2,"-"," ")),SEARCH("/",TRIM(SUBSTITUTE(A2,"-"," ")))-2,FIND(" ",TRIM(SUBSTITUTE(A2,"-"," ")),SEARCH("/",TRIM(SUBSTITUTE(A2,"-"," "))))-SEARCH("/",TRIM(SUBSTITUTE(A2,"-"," ")))+2))+0

2nd Date
=TRIM(RIGHT(SUBSTITUTE(SUBSTITUTE(A2,")",""),"-",REPT(" ",LEN(A2))),LEN(A2)))+0
 
Upvote 0
Hello VBA Geek - Is there something I need to change in the formula or vba code to get the correct end date values in column c? I used what you provided for column B and it worked perfectly.
 
Upvote 0
Try the formula in:

B2:

=TRIM(SUBSTITUTE(SUBSTITUTE(MID(A2,FIND("/",A2)-2,FIND("-",A2,FIND("/",A2))-FIND("/",A2)+2),"(",""),"-",""))

C2:

=TRIM(SUBSTITUTE(SUBSTITUTE(MID(A2,FIND("-",A2,FIND("/",A2)),20),")",""),"-",""))
Excel Workbook
ABC
1
2Water Escrows 1/1/2015-1/31/151/1/20151/31/15
3BROCHI- 2014 Water Escrow Catch-up 1/1/14-8/31/141/1/148/31/14
4Water Usage 3/31/14 - 6/30/143/31/146/30/14
5Water Usage 09/12/14 - 10/14/1409/12/1410/14/14
6Water Usage -4/28/14-5/28/144/28/145/28/14
7Water Usage 4/30/14-5/30/144/30/145/30/14
8Water True-up 4/30/14 - 6/30/144/30/146/30/14
9Water True-up 6/30/14-9/2/146/30/149/2/14
10Water Usage (07/11/14-08/06/14)07/11/1408/06/14
11Water Usage 5/23/14-6/25/145/23/146/25/14
12Water Usage 09/11/14-10/10/1409/11/1410/10/14
13Water Usage (7/11/14-08/06/14)7/11/1408/06/14
Sheet
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,964
Members
452,371
Latest member
Frana

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