string Date with day of week into mm/dd/yyyy in VBA

Rfcolon428

New Member
Joined
Feb 1, 2019
Messages
8
I have a column with the following info in a range of cells
[TABLE="width: 389"]
<tbody>[TR]
[TD="class: xl63, width: 389"]Tue Mar 05 2019,

I was looking at some examples for CDate, but I have the day of week in there as well. I think I would need to delete the first 3 char and then apply Cdate.

How would I convert that to 03/05/2019?




[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
I have a column with the following info in a range of cells
[TABLE="width: 389"]
<tbody>[TR]
[TD="class: xl63, width: 389"]Tue Mar 05 2019,

I was looking at some examples for CDate, but I have the day of week in there as well. I think I would need to delete the first 3 char and then apply Cdate.

How would I convert that to 03/05/2019?
[/TD]
[/TR]
</tbody>[/TABLE]
Is that comma after 2019 actually in the cell?

What range of cells are these text dates in... a single column, a single row or a two-dimensional range of cells? Also, can you tell us the address for whichever it is?

Your posted example shows two space characters between the month and day number... is that actually what is in your cells?
 
Last edited:
Upvote 0
Assuming the text date is in A1:

[b1] = CDate(Right([a1], Len([a1]) - 4))
[b1].NumberFormat = "mm/dd/yyyy"
 
Upvote 0
Your use of CDate seemed to indicate you wanted a macro. Give this one a try...
Code:
Sub Macro1()
  With Range("I1", Cells(Rows.Count, "I").End(xlUp))
    .TextToColumns , xlFixedWidth, FieldInfo:=Array(Array(0, 9), Array(4, 3))
    .NumberFormat = "mm/dd/yyyy"
  End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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