Consulting

Results 1 to 5 of 5

Thread: Urgent help Run tiME error

  1. #1
    VBAX Tutor
    Joined
    Dec 2008
    Posts
    244
    Location

    Urgent help Run tiME error

    my macro was wrong all day but suddenly out of no where i get a run time error message "runtime error "13': type mismatch"

    [vba]
    Range("R1").Value = CDate(UserForm1.datestart.Text)
    [/vba]

    It worked all day, I try to run just that then i work. can someone help me.

    thanks

  2. #2
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Most likely, you entered a value into (what I am guessing to be, as you gave no description) a textbox, wherein said value is unrecognizable to Excel as a date. That is, a value like "12/151/60" or "02211960" or any value that Excel could not coerce to a date.

    Hope this helps,

    Mark

  3. #3
    VBAX Tutor
    Joined
    Dec 2008
    Posts
    244
    Location
    it worked all along, and it also work when I do it by itself also

  4. #4
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Quote Originally Posted by chungtinhlak
    it worked all along, and it also work when I do it by itself also
    Greetings,

    So it is now working? By the way, you can prevent bad data entry errors by insisting the user enters using specified formatting by using the exit event to the textbox.

    [vba]Private Sub datestart_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    '// Stop user from entering some val that Excel cannot understand as a date by //
    '// checking the value entered. If the user entered a value, and it's //
    '// formatted mm/dd/yy, or mm/dd/yyyy, or mm-dd-yy, or mm-dd-yyyy... then we're //
    '// fine. If not, warn user and empty the textbox. //

    If Not datestart.Value Like "##/##/##" _
    And Not datestart.Value Like "##/##/####" _
    And Not datestart.Value Like "##-##-##" _
    And Not datestart.Value Like "##-##-####" _
    And Not datestart.Value = Empty Then

    MsgBox "You must enter a date in the proper format, such as mm/dd/yy or ..." & _
    "(Etc, your message)", 0, ""

    datestart.Text = Empty
    End If


    End Sub[/vba]

    Hope this helps ,

    Mark

  5. #5
    VBAX Tutor
    Joined
    Dec 2008
    Posts
    244
    Location
    Still not working, but if I create a new sub with the exact same thing in it, it will work.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •