Msgbox if todays date is less than date in range??

BDexcel

New Member
Joined
Jun 28, 2017
Messages
44
Can someone help please?

I have a range of cells (B2-E10) which have a number of important dates I require to track.

Can I code that when I open the workbook if todays date is less than or equal to the 5 dates leading up to any of the important dates a msgbox will appear?

Any help appreciated.
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Try this pasted into the "ThisWorkbook" module...

Don't forget to change the sheet name if needed.

Code:
Private Sub Workbook_Open()
    Dim i As Integer
    Dim dt As Range: Set dt = Worksheets("Sheet1").Range("B2:E10")
    For i = 1 To dt.Cells.Count
        If dt(i).Value - Date <= 5 And dt(i).Value - Date > 0 Then MsgBox dt(i) & " Is Due In " & dt(i).Value - Date & " Days"
    Next
End Sub
 
Last edited:
Upvote 0
You're welcome. Thanks for the feedback!
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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