VBA Check date with message box

Chickenmanc

New Member
Joined
Mar 26, 2019
Messages
8
Hello,

I have multiple cell to check just doing one to test at the moment. I have a date in that is input to that cell I want to run a check to make sure its 3 months in the future. If not pop-up a message box letting the user know check the date.

Code:
Sub check_for_errors()
Dim cd As Date
cd = DateSerial(Year(Date), Month(Date) + 3, 1)
        
        If activeworksheet.Range("H23") < cd Then
            MsgBox "check your date"
        Else
        End If
        
End Sub
[code]
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Check out and use the...
WorksheetFunction.EDATE(DATE, 3)
which should produce 7/11/2019
To compare to. You might need to add +1 or -1 to get exactly the cut-off date.

Jim
 
Upvote 0

Forum statistics

Threads
1,224,930
Messages
6,181,825
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