Extract Date from Text String - Format DD.MM

jpagett9

New Member
Joined
Nov 14, 2017
Messages
3
Hi guys,

I have a column with comments/text string in each cell and I am looking to pull just the date, in the format "DD.MM" using some sort of VBA code. The dates do not always occur at the start of the comment/text string. Sometimes in the middle also.

Is there any way to do this?

Thanks all!
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Hi
Welcome to the board

2 or 3 examples of the text in the cells would help.
That would answer, for ex., is the dot in DD.MM is the only dot in the text?
 
Upvote 0
Hi,

So for example, in cell AW2 of my sheet, I may have the following:

30.11 GG - Spoke to Jess, she is unavailable at this time.
28.10 CG - Tried calling but was unable to reach. Need to try email at jess.bloggs@maill.co.uk

There is usually more than one line of information per cell (like above). Furthermore, there is usually more than one dot also. Unfortunately, it is entered manually, so there is inconsistency between formatting, which is why I am having issues extracting the dates.

Thanks a lot for your help
 
Upvote 0
Those, of course, are not real dates, so I am not sure what you want in the cells they are pulled out to. In the following macro, I pull them out exactly as they are, but as numbers custom formatted as "00.00". If this is not correct, please clarify what you want in some detail (so we do not have to guess)...
Code:
Sub GetDates()
  Dim R As Long, X As Long, LastRow As Long, Parts() As String
  LastRow = Cells(Rows.Count, "AW").End(xlUp).Row
  For R = 1 To LastRow
    Parts = Split(Cells(R, "AW").Value, vbLf)
    For X = 0 To UBound(Parts)
      Cells(R, "AX").Offset(, X).Value = Val(Parts(X))
      Cells(R, "AX").Offset(, X).NumberFormat = "00.00"
    Next
  Next
End Sub
 
Upvote 0
Hi

In your examples the date is the first 5 characters.

For that case, you can use a simple formula:

=DATE(2017,MID(A1,4,2),LEFT(A1,2))
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,159
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