Macro with Message Box for Date Greater Than Today

rhmkrmi

Active Member
Joined
Aug 17, 2012
Messages
348
Office Version
  1. 365
Platform
  1. Windows
Hi there, I need a VBA to be used in Excel to check a couple of columns (F:F, H:H, N:N) to see if any cell in those columns contain a date that is greater than today and pop up a message. Could you please help?

Thank you.
 
When it finds the future dates the first time it pops up a message and then any data entry whether it is text or date in any cell triggers the message to pop-up!
I want it to pop-up once any time a future date is entered in columns F, H, and M.

Thank you.
 
Upvote 0

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
When it finds the future dates the first time it pops up a message and then any data entry whether it is text or date in any cell triggers the message to pop-up!
Yes, that is exactly what you asked for‼


I want it to pop-up once any time a future date is entered in columns F, H, and M.
Then maybe this? This will give the message once.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    On Error Resume Next
    If Len(ThisWorkbook.Names("FutureDate").Name) > 0 Then DoEvents
    If Err <> 0 Then ThisWorkbook.Names.Add Name:="FutureDate", RefersTo:=False
    On Error GoTo 0

    If ThisWorkbook.Names("FutureDate").RefersTo = "=FALSE" Then
        If Application.WorksheetFunction.Max(Columns("F"), Columns("H"), Columns("N")) > Date Then
            ThisWorkbook.Names("FutureDate").RefersTo = True
            MsgBox "Please check your dates"
        End If
    End If

End Sub
If you want some other variation please modify to suit.
 
Upvote 0

Forum statistics

Threads
1,224,929
Messages
6,181,819
Members
453,067
Latest member
mdiz777

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top