Extract a date from a string of text

JeffFinnan

Board Regular
Joined
Aug 12, 2020
Messages
61
Office Version
  1. 2019
Platform
  1. Windows
I have a cell with that has text and a date in it for example: QAQC Data was downloaded at 9/30/24 2:08 PM

Is there a way to simply extract just the date out of this using vba? This cell will always be in this format.
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Here is one way:
VBA Code:
Sub ExtractDate()

    Dim str As String
    Dim arr() As String
    Dim myDate
    
    str = "QAQC Data was downloaded at 9/30/24 2:08 PM"
    arr = Split(str, " ")

    myDate = arr(UBound(arr) - 2)
    MsgBox myDate
    
End Sub
 
Upvote 0
Try:

Libro1
AB
1
2QAQC Data was downloaded at 9/30/24 2:08 PM9/30/24
Hoja2
Cell Formulas
RangeFormula
B2B2=TRIM(MID(A2,SEARCH("??/??/????",A2),8))
 
Upvote 0
With macro:

VBA Code:
Sub Macro1()
  Range("B2").Value = Evaluate("=TRIM(MID(A2,SEARCH(""??/??/????"",A2),8))")
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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