Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Validating Dates

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Validating Dates

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Validating Dates

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Validating Dates

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Validating Dates

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Validating Dates

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Validating Dates

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Validating Dates

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 230
Default Validating Dates

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
sumproduct - validating codes & dates Chuck[_3_] Excel Worksheet Functions 3 November 14th 07 01:12 AM
validating Ayesha Excel Worksheet Functions 2 April 26th 06 02:56 PM
Validating Sdbenn90 Excel Discussion (Misc queries) 0 March 27th 06 12:05 AM
Validating Dates Entered patam Excel Discussion (Misc queries) 2 September 2nd 05 05:36 PM
Event validating two ranges with dates G R E G Excel Programming 1 August 9th 03 12:03 AM


All times are GMT +1. The time now is 02:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"