View Full Version : Urgent help Run tiME error
chungtinhlak
12-08-2008, 04:52 PM
my macro was wrong all day but suddenly out of no where i get a run time error message "runtime error "13': type mismatch"
Range("R1").Value = CDate(UserForm1.datestart.Text)
It worked all day, I try to run just that then i work. can someone help me.
thanks
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
chungtinhlak
12-08-2008, 05:19 PM
it worked all along, and it also work when I do it by itself also
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.
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
Hope this helps:) ,
Mark
chungtinhlak
12-08-2008, 06:12 PM
Still not working, but if I create a new sub with the exact same thing in it, it will work. :(
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.