求用VBA宏
在A1单元格输入日期,A2单元格输入密码, 要求每次打开EXCEL 判断,当 当天日期小于A1日期时,则inputbox ("请输入你的使用权限密码?"),如密码错误 MsgBox "密码错误,请按确定退出",ThisWorkbook.Close , 如密码等于A2的值,则可进入EXCel
程序代码:
Private Sub Workbook_Open() Dim str As String With Sheet1 If Date < .Range("a1") Then res: str = InputBox("输入密码:", "Passwd") If StrPtr(str) = 0 Then Application.Quit ElseIf str = .Range("a2") Then MsgBox "welcome!" ElseIf str <> .Range("a2") Then MsgBox "密码错误" GoTo res: End If Else MsgBox "系统日期>=a1" Application.Quit End If End With End Sub