Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm trying to validate dates whuen I make an input ("dd/mm/yy"). I use the
routine If IsDate(txtFFinal) Then MsgBox "Date is correct" else MsgBox "Date is correct" End If When I enter the date 31/06/2005 it assumes it's a correct date. Any suggestions? Thanks Luis Verme |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Luis,
If I am reading your code correctly any date you pass it will be correct, both sides of your if statement are the same? Regards, James |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Oops.
It's If IsDate(txtFFinal) Then MsgBox "Date is correct" else MsgBox "Date is incorrect" End If escribió en el mensaje oups.com... Hi Luis, If I am reading your code correctly any date you pass it will be correct, both sides of your if statement are the same? Regards, James |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
But of course it still doesn't work
"Luis Verme" escribió en el mensaje ... Oops. It's If IsDate(txtFFinal) Then MsgBox "Date is correct" else MsgBox "Date is incorrect" End If escribió en el mensaje oups.com... Hi Luis, If I am reading your code correctly any date you pass it will be correct, both sides of your if statement are the same? Regards, James |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
What are you inputting to? a userform, spreadsheet etc.
I tried putting your code behind a userform textbox and it worked fine. If its on the spreadsheet then I think that depends on your regional settings as to whether its a correct date, ie in the Uk 31/06/2005 is a valid date. Regards, James |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Bunter,
ie in the Uk 31/06/2005 is a valid date. Certainly NOT in the UK and not in any country that I've encountered! June has only 30 days. --- Regards, Norman wrote in message ups.com... What are you inputting to? a userform, spreadsheet etc. I tried putting your code behind a userform textbox and it worked fine. If its on the spreadsheet then I think that depends on your regional settings as to whether its a correct date, ie in the Uk 31/06/2005 is a valid date. Regards, James |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Luis,
I tried: Sub Tester01() MsgBox IsDate("31/6/2005") MsgBox IsDate("30/6/2005") MsgBox IsDate("31/02/2005") End Sub and received the responses: False True False - as expected However, trying: Sub Tester02() MsgBox IsDate("31/6/05") MsgBox IsDate("30/6/05") MsgBox IsDate("31/02/05") End Sub I received a True response in each case, which surprised me. In any event, using the full 4-digits for the year I could not reproduce your experience. --- Regards, Norman "Luis Verme" wrote in message ... But of course it still doesn't work "Luis Verme" escribió en el mensaje ... Oops. It's If IsDate(txtFFinal) Then MsgBox "Date is correct" else MsgBox "Date is incorrect" End If escribió en el mensaje oups.com... Hi Luis, If I am reading your code correctly any date you pass it will be correct, both sides of your if statement are the same? Regards, James |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi guys.
Thank you for all your suggestions. As Norman said, I changed to a 4 digit year date and worked fine. Thanks again Luis Verme "Norman Jones" escribió en el mensaje ... Hi Luis, I tried: Sub Tester01() MsgBox IsDate("31/6/2005") MsgBox IsDate("30/6/2005") MsgBox IsDate("31/02/2005") End Sub and received the responses: False True False - as expected However, trying: Sub Tester02() MsgBox IsDate("31/6/05") MsgBox IsDate("30/6/05") MsgBox IsDate("31/02/05") End Sub I received a True response in each case, which surprised me. In any event, using the full 4-digits for the year I could not reproduce your experience. --- Regards, Norman "Luis Verme" wrote in message ... But of course it still doesn't work "Luis Verme" escribió en el mensaje ... Oops. It's If IsDate(txtFFinal) Then MsgBox "Date is correct" else MsgBox "Date is incorrect" End If escribió en el mensaje oups.com... Hi Luis, If I am reading your code correctly any date you pass it will be correct, both sides of your if statement are the same? Regards, James |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Norman,
What is surprising? Just put this in Immediate Window and the answer is clear :-) ?format(("31/6/05"),"M/D/YYYY") "Norman Jones" wrote in message ... Hi Luis, I tried: Sub Tester01() MsgBox IsDate("31/6/2005") MsgBox IsDate("30/6/2005") MsgBox IsDate("31/02/2005") End Sub and received the responses: False True False - as expected However, trying: Sub Tester02() MsgBox IsDate("31/6/05") MsgBox IsDate("30/6/05") MsgBox IsDate("31/02/05") End Sub I received a True response in each case, which surprised me. In any event, using the full 4-digits for the year I could not reproduce your experience. --- Regards, Norman "Luis Verme" wrote in message ... But of course it still doesn't work "Luis Verme" escribió en el mensaje ... Oops. It's If IsDate(txtFFinal) Then MsgBox "Date is correct" else MsgBox "Date is incorrect" End If escribió en el mensaje oups.com... Hi Luis, If I am reading your code correctly any date you pass it will be correct, both sides of your if statement are the same? Regards, James |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
sumproduct - validating codes & dates | Excel Worksheet Functions | |||
validating | Excel Worksheet Functions | |||
Validating | Excel Discussion (Misc queries) | |||
Validating Dates Entered | Excel Discussion (Misc queries) | |||
Event validating two ranges with dates | Excel Programming |