Transferring date from userform to spreadsheet

  • Hi

    Several references online to this but I am missing something. "Reafidy July 2007" seemed appropriate but returns error 13 mismatch

    I keep wondering if it doesn't like the format "dd:mmm:yy"



    I have a text box in userform initialize displaying current date as "dd:mmm:yy" which works and displays as it should.


    Code
       txtread.Value = Range("f8").Offset(0, -3).Value
        txtbill.Value = Range("f8").Offset(0, -2).Value
        txtcurrdate.Value = Format(Now(), "dd:mmm:yy")

    I am trying to transfer/copy date from txtcurrdate to spreadsheet activecell.


    If I use activecell.value = txtcurrdate.value this returns the data but not in date format.


    Any help on this I would be grateful. Thanks a lot

  • I assume you actually want a date value in the cell.


    Possibly replacing the ":" with "-" first before would work


    Code
    Dim FirstBlankCell As Range
    
    Set FirstBlankCell = Range("B" & Rows.Count).End(xlUp).Offset(1, 0)
    With FirstBlankCell
        nd = Replace(Me.txtcurrdate, ":", "-")
        .Value = nd
        .NumberFormat = "dd:mmm:yy"
    End With
  • Try this


  • If that doesn't work try DateValue



Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!