How to Create Excel VBA Due-Date Notifications (28, 14, 7 Days)
Question details
The user needs to build an automated VBA macro that calculates the days remaining until a specified due date and triggers pop-up alerts exactly 28, 14, and 7 days prior.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Tracking project deadlines or tasks in a spreadsheet and requiring automatic system reminders as the target dates approach.
- Observed behavior
- The user wants a script that executes automatically upon opening the workbook, validating the date, calculating the difference, and displaying a message box at the specified intervals.
Ensure your workbook is saved as a Macro-Enabled Workbook (.xlsm) and that you have enabled macros in your Trust Center settings so the automation can run when the file opens.
Use VBA DateDiff with the Workbook_Open Event
This solution calculates the exact days remaining between today and the target date, automatically displaying a message box if the difference is exactly 28, 14, or 7 days.
By placing the code in the Workbook_Open event, the check happens automatically the moment you open the file. The DateDiff function reliably calculates the days between the current system date and your recorded due date.
Press Alt + F11 on your keyboard to open the Microsoft Visual Basic for Applications window.
In the Project Explorer pane on the left, find your active workbook and double-click on 'ThisWorkbook'.
From the left dropdown menu at the top of the code window, select 'Workbook'. The right dropdown will automatically select the 'Open' event.
Inside the Private Sub Workbook_Open() block, declare your variables (Dim DueDate As Date, DaysLeft As Integer). Use an If statement with IsDate(Range("A1").Value) to verify the cell contains a date.
Set DaysLeft = DateDiff("d", Date, DueDate). Add another If statement: If DaysLeft = 28 Or DaysLeft = 14 Or DaysLeft = 7 Then MsgBox "You have " & DaysLeft & " days left!", vbInformation.

Create a Range-Based Countdown Notification
Use this alternative if you do not open the file every day and want the notification to appear any time you open the file within a specific timeframe (e.g., between 14 and 28 days).
Use WPS Spreadsheets to Run VBA Macros Seamlessly
WPS Office offers comprehensive support for VBA macros in its advanced editions, allowing you to run your Excel automation scripts, including date notifications and custom pop-ups, without modifying your code.
- 1. Open Your File in WPS: Download and install WPS Office. Open your macro-enabled workbook (.xlsm) using WPS Spreadsheets.
- 2. Access the Developer Tools: Navigate to the Developer tab on the top ribbon and click on 'VBA Editor' to view or edit your macro scripts.
- 3. Run Your Reminders: Ensure macros are enabled in your security settings. Your Workbook_Open notifications will trigger exactly as they do in Microsoft Excel.

Frequently Asked Questions
Why isn't my VBA notification popping up when I open the workbook?
This usually happens if macro security settings are blocking the script from running automatically, or if the code was placed in a standard Module instead of the ThisWorkbook object under the Workbook_Open event.
How can I check multiple rows for due dates instead of just cell A1?
You will need to use a 'For Each' loop in your VBA code to iterate through a range of cells (for example, Range("A2:A100")). The loop can calculate the DateDiff for each cell and trigger an alert if any of them meet the 28, 14, or 7-day condition.
Will DateDiff work properly if my computer's regional date format is different?
Yes, DateDiff evaluates the underlying serial number of the date rather than the displayed text format, as long as the cell contains a valid date value recognizable by Excel.
Can I format the MsgBox to show a warning icon?
Yes. When calling the MsgBox function, you can change the 'vbInformation' parameter to 'vbExclamation' or 'vbCritical' to display different warning icons inside the pop-up.




