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

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
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,223,958
Messages
6,175,629
Members
452,661
Latest member
Nonhle

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