+ Reply to Thread
Results 1 to 2 of 2

How do I check if a variable is in the date format?

Hybrid View

  1. #1
    Registered User
    Join Date
    07-05-2006
    Posts
    16

    How do I check if a variable is in the date format?

    I want to check to make sure the contents of a cell is in the date format before I run a DateDiff so as to avoid possible errors, any idea how I could do that?

  2. #2
    Registered User
    Join Date
    09-06-2004
    Posts
    37
    Use the IsDate function. It returns True if the reference is recognizable as a date and False if it's not. Example:

    Sub dtechck()
    If IsDate(Range("A1")) Then
    Range("B1").Value = "a Date"
    Else: Range("B1").Value = "no Date"
    End If
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1