+ Reply to Thread
Results 1 to 3 of 3

Thread: Date Check

  1. #1
    Registered User
    Join Date
    09-05-2011
    Location
    St. John's, Canada
    MS-Off Ver
    Excel 2010
    Posts
    71

    Date Check

    Hello All,

    I've created a Macro that takes Data from daily reports and imports them into a master work book, within that macro I have a "Date Check" to insure that there are no common errors( Wrong year, wrong month). At first it seem to work fine, but now no matter what the date on the Daily Report, I recieve my message prompt asking if I would like to continue... am I using the date function properly ?

    Dim Today As Double
    Today = Worksheets("Daily Report(WR)").Cells(6, "C").Value
    LoopExit = 0
    
    If Today - 30 < Date - 30 Then
             If MsgBox("This Daily Report(WR) is over 30 Days old. Would you like to Continue Anyway?", vbYesNo + vbQuestion, "Search Not Found") = vbNo Then
             Exit Sub
            End If
         End If
    
    If Today >= Date + 1 Then
             If MsgBox("This Daily Report(WR) seems to be from the future? Would you like to Continue Anyway? Suggest that the report date be checked for errors.", vbYesNo + vbQuestion, "Search Not Found") = vbNo Then
             Exit Sub
            End If
         End If

  2. #2
    Valued Forum Contributor tlafferty's Avatar
    Join Date
    04-08-2011
    Location
    United States, Tacoma, WA
    MS-Off Ver
    Excel 2010
    Posts
    856

    Re: Date Check

    I'd use a different variable name than Today as it's a reserved word for an Excel worksheet function. Try using CurrentDate instead of Today.
    If your question has been satisfactorily addressed, please consider marking it solved. Click here to see how.

    Also, you might want to add to the user's reputation by clicking the scales icon - it's why we do what we do...

    Thomas Lafferty
    Analyst/Programmer

  3. #3
    Registered User
    Join Date
    09-05-2011
    Location
    St. John's, Canada
    MS-Off Ver
    Excel 2010
    Posts
    71

    Re: Date Check

    Thanks for the advice tlaffery but still no luck I get the same thing ... the Report Date is Sept 27 2011 and the prompt still says its 30 days old

+ Reply to Thread

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.2.0