Results 1 to 3 of 3

Error with Type Mismatch

Threaded View

  1. #1
    Registered User
    Join Date
    09-08-2009
    Location
    Glasgow
    MS-Off Ver
    Excel 2003 SP3
    Posts
    45

    Question Error with Type Mismatch

    Hey there, I am trying to check a user input to see if the user has entered the date correctly.

    I am using the code below but it keeps giving me a "Type Mismatch" error. Does anyone know where I am going wrong?

    Sub remove_old_data()
    
    Dim dateDim As String
    
    Do While (date_check(dateDim) = 1)
    
        dateDim = InputBox(Prompt:="Please enter the date you wish to filter from: ", _
              Title:="Date Filter", Default:="Date filter")
    Loop
    
    End Sub
    
    
    Function date_check(datePar As String)
    
    If (Format(datePar) <> Format(CDate(datePar), "DD/MM/YYYY")) Then 'checks if the format of the cell is equivalent to "DD/MM/YYYY", as required for import
            MsgBox "Please enter the date in the format ""DD/MM/YYYY"".", vbInformation, "Remove Old Data"
            'highlights in which cell the error took place
            date_check = 1                      'returns a 1 to indicate an error has occured
            Exit Function                       'exits the function
        Else
            date_check = 0
        End If
        
    End Function
    Any help would be greatly appreciated, thanks.

    Jag
    Last edited by therealjag; 02-17-2010 at 10:30 AM.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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