With these changes it should work better.
Option Explicit
Private Sub Workbook_Open()
Dim d1 As Date
Dim d2 As Date
Dim password As String
d1 = CDate("10/02/2021")
d2 = Date
If d2 > d1 Then
password = InputBox("enter password")
Else
MsgBox ("Opening file")
Exit Sub
End If
pwd:
If password = "abC123_" Then
MsgBox ("Welcome!")
Exit Sub
Else
MsgBox ("Incorrect password!")
password = InputBox("enter password again")
If password = "" Then
MsgBox ("No password ... no party ...")
ThisWorkbook.Close False
End If
GoTo pwd
End If
End Sub
Bookmarks