Forum Discussion

MHT1974's avatar
MHT1974
Copper Contributor
Mar 24, 2025
Solved

VBA to convert MMM DD YYYY to date

Hi All,  I am looking for an Excel VBA code that would e.g. check in Col D if the date is already in date format and if not convert it from text to date format and repeat this for all populated cell...
  • HansVogelaar's avatar
    HansVogelaar
    Apr 07, 2025

    Thank you. Try this:

    Sub Convert2Date()
        Dim rng As Range
        Dim cel As Range
        Application.ScreenUpdating = False
        On Error Resume Next
        Set rng = Range(Range("D2"), Range("D" & Rows.Count).End(xlUp))
        rng.NumberFormat = "m/d/yyyy"
        For Each cel In rng
            cel.Value = CDate(cel.Value)
        Next cel
        Application.ScreenUpdating = True
    End Sub

     

Resources