Find date text in cell (Variable text format)

Searshc

New Member
Joined
May 9, 2013
Messages
21
I have a cell containing text strings that vary wildly. For example, a common cell might read: Steven Bruce 738226 (LA) New 5/2 **LG**

I only need to look for and extract the date value, but here's the rub: People have the date listed as 5/2, or 5/2/15, or 5/02/2015, etc. I need a way to pull the date regardless of how people formatted it. I have been trying to use
=VALUE(MID($N4,SEARCH("?/?",$N4),9)))

It solves for it sometimes, depending on the format, but other times it doesn't. What can I use to find the date value? It is always in a text cell, and always mixed up with other names/numbers. The only absolute is that the date can be recognized by the slash "/".
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
It's easy if the date is always surrounded by spaces:

Plan4

*F
*

<tbody>
[TD="bgcolor: #cacaca, align: center"]9[/TD]
[TD="align: center"]Steven Bruce 738226 (LA) New 5/2 **LG**[/TD]

[TD="bgcolor: #cacaca, align: center"]10[/TD]

[TD="bgcolor: #cacaca, align: center"]11[/TD]
[TD="align: center"]5/2[/TD]

</tbody>

Spreadsheet Formulas
CellFormula
F11=ExtractDate("f9")

<tbody>
</tbody>

<tbody>
</tbody>

Code:
' place this in a module

Function ExtractDate$(r$)
Dim a, i%
a = Split(Range(r), " ")
For i = LBound(a) To UBound(a)
    If InStr(a(i), "/") > 0 Then
        ExtractDate = a(i)
        Exit Function
    End If
Next
End Function
Excel tables to the web >> Excel Jeanie HTML 4
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,246
Members
452,623
Latest member
cliftonhandyman

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