Is there a way in which I can make the text box password protected in excel VBA. I want to make the contents of the textbox password protected so that if anyone one wants to change the values of the text box, it asks them the password.
Thanks
You have specified "This is the textbox on the sheet with ActiveX control"
In that sheet's code module, enter this code:
Private Sub TextBox1_GotFocus()
Dim Password As String
Password = InputBox("Enter password to edit this field:", "Password")
If Password <> "MyPassword123" Then Me.Range("A1").Select
End Sub
If you want the password box to be ***
's so that the password is masked when users type it, you will need to create a userform with a textbox and have its PasswordChar
property set to *
. Then you'd call the userform and have it perform the password check.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.