Put the following formula into a cell near the cell containing the date you wish to check:
Format the cell with that formula so that the format of the date matches the format of the date of the cell containing the date you wish to check. You can also make it white so that this date isn't visible in future, it won't affect the macro.
Put this code into the ThisWorkbook code part of VBA for your workbook:
Private Sub Workbook_Open()
'Change A2 to the cell you put =TODAY() in
'Change A1 to the cell containing the date you want to check
If Range("A2") <> Range("A2") Then
MsgBox "The date of the workbook does is not today's date! Please change it accordingly.", vbCritical, "Error"
Else
MsgBox "The date of the workbook is today's date."
End If
End Sub
Bookmarks