Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Nov 2003
    Location
    Queensland, Australia
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Validating a date in a userform (excel 2000)

    Hi, I'm new to this forum and I'm hoping someone may have some ideas;
    I'm trying to validate a date entered in a userform (in the format 24/11/2003), and can't seem to get the validation code right in VBA? Anyone have any ideas? Anyone know how to code for the current system date in VBA (in excel)?

    Thanks
    Matthew

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Validating a date in a userform (excel 2000)

    1. The VBA function IsDate returns True if the argument is a valid date, False otherwise, so you can use something like

    If IsDate(Me.TextBox1) Then
    ...
    Else
    ...
    End If

    2. The VBA function Date (no arguments) returns the current date.

    Both are general VBA functions, they are not specific to Excel.

  3. #3
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Validating a date in a userform (excel 2000)

    Be Aware:
    VB seems to be very "US-based" in dates (much more so than excel is). So you might get strange results and might want to do some tests and create routines to check.

    Steve

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •