VBA & Macro Problems

How to Create Excel VBA Due-Date Notifications (28, 14, 7 Days)

Nimra MalikNimra Malik Nov 11, 2026 870 views

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.

Create Excel VBA Due-Date Notifications at 28, 14, and 7 Days
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.
Before you start

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.

Solution 1Recommended

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.

1
Open the VBA Editor

Press Alt + F11 on your keyboard to open the Microsoft Visual Basic for Applications window.

2
Access ThisWorkbook

In the Project Explorer pane on the left, find your active workbook and double-click on 'ThisWorkbook'.

3
Create the Open Event

From the left dropdown menu at the top of the code window, select 'Workbook'. The right dropdown will automatically select the 'Open' event.

4
Insert the Notification Code

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.

5
Calculate and Trigger the Alert

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.

Use VBA DateDiff with the Workbook_Open Event
Cell Reference: This script assumes your due date is in cell A1 of the active sheet. Update Range("A1") to match the actual cell containing your deadline.
Automate Spreadsheets with WPS

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. 1. Open Your File in WPS: Download and install WPS Office. Open your macro-enabled workbook (.xlsm) using WPS Spreadsheets.
  2. 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. 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.
Fully compatible with Microsoft Excel .xlsm and .xlsb macro-enabled formatsNatively supports standard VBA syntax, including DateDiff, MsgBox, and Workbook eventsLightweight application that opens complex macro-enabled files quicklyIntuitive Developer tab for easy macro management
microsoft office alternative - wps office

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.