Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Checking format on input
Hi I am writing a macro in VisualBasic 6.3. In an Excel-spreadsheet the user
is supposed to write two dates in two different cells. When pressing a button defined in my macro the dates submitted by the user shall be stored as a variable and checked. The checking is to see that the date is written properly e.g. YYYY-MM-DD. How do I preform this check? Is it possible to see if the dates gives by the user are non-existing? Any help is appreciated! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Checking format on input
How about using Data Validation, which has a date type, and you can specify
upper and lower limits on the date. -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Jenni_Sweden" wrote in message ... Hi I am writing a macro in VisualBasic 6.3. In an Excel-spreadsheet the user is supposed to write two dates in two different cells. When pressing a button defined in my macro the dates submitted by the user shall be stored as a variable and checked. The checking is to see that the date is written properly e.g. YYYY-MM-DD. How do I preform this check? Is it possible to see if the dates gives by the user are non-existing? Any help is appreciated! |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Checking format on input
Hi Jenni,
You could use Excel's data validation on the date input cells to catch any errors right at the input stage. The only caveat is that if a user copies and pastes in a date from another cell location which doesn't have validation, this will wipe out the existing validation test (a bug in my opinion). If you're reasonably certain your users won't be pasting input values into the validated date cells then data validation is the way to go. Otherwise you can do a high-level check in VBA to ensure that the entered values are indeed dates by using the IsDate function: If Not (IsDate(Input Range)) Then MsgBox "You must enter a date in the date field" You can of course also build your own data validation by checking the VBA.Year, VBA.Month, and VBA.Day values against whatever criteria you'd like. "Jenni_Sweden" wrote: Hi I am writing a macro in VisualBasic 6.3. In an Excel-spreadsheet the user is supposed to write two dates in two different cells. When pressing a button defined in my macro the dates submitted by the user shall be stored as a variable and checked. The checking is to see that the date is written properly e.g. YYYY-MM-DD. How do I preform this check? Is it possible to see if the dates gives by the user are non-existing? Any help is appreciated! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Checking usewr has input a valid address | Excel Programming | |||
Checking user has input a valid address. | Excel Programming | |||
Checking Input box | Excel Programming | |||
checking input on a textbox in userform to be a % | Excel Programming | |||
Checking input for alphabet (i.e. words) | Excel Programming |