我用密码保护了工作表名称“Profit Loss Statement”。它运行良好,但输入时可以看到密码。所以我想掩盖密码。 这是我的代码。
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
ActiveWorkbook.Unprotect
Dim MySheets As String, Response As String
Dim ex As Long
MySheets = "Profit Loss Statement"
If ActiveSheet.Name = MySheets Then
ActiveSheet.Visible = False
Response = InputBox("Enter password to view Profit & Loss")
If Response = "abcd" Then 'password is abcd and to be asked
Sheets(MySheets).Visible = True
Application.EnableEvents = False
Sheets(MySheets).Select
Application.EnableEvents = True
ActiveWorkbook.Protect
Else
MsgBox "Incorrect Password"
End If
End If
Sheets(MySheets).Visible = True
ActiveWorkbook.Protect
End Sub
答案 0 :(得分:0)
我所知道的是输入框无法屏蔽字符。在userform中使用文本框,并使其属性“PasswordChar”等于*。