Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 84
Default 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
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
Checking usewr has input a valid address Peter Rooney Excel Programming 4 March 8th 06 10:11 AM
Checking user has input a valid address. Peter Rooney Excel Programming 1 March 7th 06 10:57 PM
Checking Input box AMK4[_15_] Excel Programming 21 January 26th 06 05:32 AM
checking input on a textbox in userform to be a % Jean-Pierre D via OfficeKB.com Excel Programming 11 August 25th 05 11:39 PM
Checking input for alphabet (i.e. words) Neal[_5_] Excel Programming 1 February 12th 04 01:50 AM


All times are GMT +1. The time now is 03:46 PM.

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

About Us

"It's about Microsoft Excel"