mole999
Well-known Member
- Joined
- Oct 23, 2004
- Messages
- 10,524
- Office Version
- 2019
- 2016
- 2013
- Platform
- Windows
Just imported a load of CSV values that came across as 1/15/2019 12:22 date and time
I was following > https://www.mrexcel.com/forum/excel-questions/1086344-formatting-dates.html which works when no time value is involved.
Just wondering if a small vba script could be developed that would strip the time value and then invert the date to 15/01/2019. something on the lines of
I'm sure there would be many users for this simple concept
=IF(ISTEXT(D1020),DATEVALUE(MID(D1020,FIND("/",D1020,1)+1,2)&"/"&SUBSTITUTE(LEFT(D1020,2),"/","")&"/"&MID(D1020,FIND("/",D1020,4)+1,4)),D1020) works as intended, just would like to wrap in VBA
Any thoughts?
I was following > https://www.mrexcel.com/forum/excel-questions/1086344-formatting-dates.html which works when no time value is involved.
Just wondering if a small vba script could be developed that would strip the time value and then invert the date to 15/01/2019. something on the lines of
Code:
Sub nameswaper()
On Error Resume Next
Dim St As String, i As Long
St = ActiveCell.Value
i = InStrRev(St, " ")
ActiveCell.Offset(, 0).Value = UCase(Right(St, Len(St) - i)) & " " & WorksheetFunction.Proper(Left(St, i - 1))
End Sub.
=IF(ISTEXT(D1020),DATEVALUE(MID(D1020,FIND("/",D1020,1)+1,2)&"/"&SUBSTITUTE(LEFT(D1020,2),"/","")&"/"&MID(D1020,FIND("/",D1020,4)+1,4)),D1020) works as intended, just would like to wrap in VBA
Any thoughts?