Date...

  • Thread starter Thread starter TJF
  • Start date Start date
T

TJF

I heve got variable with name Example, its text. I use this varible for
entry date.
Then I used: ExampleTrue = DateValue(Example) for getting true date. When
Example is = 5/7/03 then ExampleTrue = 5.7.2003, but when Example is only
=5/ its Error. So how can I checked if Example is good entry: dd.mm.yy

Tom
 
Hi Tom

You can use the Isdate function to only run the code if
Excel recognises the text as a date.

EG If IsDate(Example) then
ExampleTrue = Datevalue(example)
else
msgbox "invalid date"
end if

this displays the messgage "Invalid date" if the user does
not enter something that excel recognises as a date.

Hope this helps
Libby
 
Hi again

With regard to my earlier reply, you need to say

If IsDate(Example) = true

Libby
 
use the isdate() function

eg
If isdate(example) then
ExampleTrue = DateValue(Example)
else
msgbox example & " is not a valid date"
end if



Patrick Molloy
Microsoft Excel MVP
 
Back
Top