+ Reply to Thread
Results 1 to 4 of 4

msgbox if todays date is past date in cell

Hybrid View

  1. #1
    Forum Contributor timtim89's Avatar
    Join Date
    01-05-2012
    Location
    Copenhagen, Denmark
    MS-Off Ver
    Excel 2010
    Posts
    141

    msgbox if todays date is past date in cell

    Hey,

    When opening a workbook, I want a msgbox to pop up, if todays date is past the date in date in cell c4.
    I tried the formula beneath, but it gives me the msgbox nomatter if the condition is met or not.
    Thanks in advance for your help and effort.

    Private Sub Workbook_Open
    With Sheets("Main")
    If Range("c4") < Date Then
    MsgBox "Workbook has expired", vbOKOnly
    Else
    Exit Sub
    End If
    End With
    
    End Sub
    Last edited by timtim89; 03-21-2012 at 07:09 PM.

  2. #2
    Forum Expert DGagnon's Avatar
    Join Date
    02-23-2012
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2003, 2007
    Posts
    1,645

    Re: msgbox if todays date is past date in cell

    try this:

    Private Sub Workbook_Open()
        If Sheets("Main").Range("c4").Value < Date Then
            MsgBox "Workbook has expired", vbOKOnly
        End If
    End Sub
    If you liked my solution, please click on the Star -- to add to my reputation

    If your issue as been resolved, please clearly state so and mark the thread as [SOLVED] using the thread tools just above the first post.

  3. #3
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: msgbox if todays date is past date in cell

    This is all you need to be honest

    Private Sub Workbook_Open
    With Worksheets("Sheet1")
        If Date > .Range("C4") Then MsgBox "Workbook has expired", vbOKOnly
    End With
    end sub

  4. #4
    Forum Contributor timtim89's Avatar
    Join Date
    01-05-2012
    Location
    Copenhagen, Denmark
    MS-Off Ver
    Excel 2010
    Posts
    141

    Re: msgbox if todays date is past date in cell

    Both solutions work great! Thanks you guys

+ 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