(Solved) – date string isn’t recognized by “Format” or “Cdate”

(solved)-–-date-string-isn’t-recognized-by-“format”-or-“cdate”

I’ve been trying for hours to convert this string into a date format variable but every try seems not to work,

here is my code:

Option Explicit

Sub date()
    Dim m1 As Range
    Dim m As String
    Dim ddate As Date
    Set m1 = Worksheets("dates").Range("A9") 
    'm1 text= "somehting 31-Jan-2019"
    m = Right(m1, 11)
    m = Replace(m, "-", "https://stackoverflow.com/") ' "31/Jan/2019
    ddate = CDate(m)

End Sub

at the end ‘ddate’ gets an error of ‘types do not match’

Leave a Reply

Your email address will not be published. Required fields are marked *