I have this code and not sure as what is wrong, it is not giving me the required result, any help
in row no 8 have this date
in row no 8 have this date
11/01/23, 00:00 | 12/01/23, 00:00 | 13/01/23, 00:00 | 01/02/23, 00:00 | 02/02/23, 00:00 | 03/02/23, 00:00 | |
Result | 11/01/23 | 12/01/23 | 13/01/23 | 01/02/23 | 02/02/23 | 03/02/23 |
11-Jan | 12-Jan | 13-Jan | 1-Feb | 2-Feb | 3-Feb |
VBA Code:
Sub TO_DATE1()
Range("R2").Select
Selection.Formula = "=IF(R8="""","""",IF(OR(R8=""NE_STATE"",R8=""Short name"",R8=""OLT""),"""",R8))"
Selection.Copy
Range("R2").Select
' Range(Selection, Selection.End(xlToRight)).Select
Range("R2:LZ2").Select
ActiveSheet.Paste
Application.CutCopyMode = False
'On Error Resume Next
Dim e As Range, te As String
For Each e In Range("R2:LZ2")
te = e.Value
If Mid(te, 2, 1) = "/" Then te = "0" & te
If Len(te) > 7 Then e = CDate(Left(te, 8))
Next
Range("R2:LZ2").NumberFormat = "dd/mm/yy"
End Sub