Passwords are crucial for user authentication in applications, combining letters, numbers, and symbols to verify identity. In Excel VBA, masking passwords (e.g., displaying asterisks instead of characters) prevents unauthorized viewing, such as "shoulder surfing" in public spaces. Unlike the standard InputBox function, which doesn't support masking, a custom UserForm allows secure input.
Steps to Mask Password in VBA Excel Input Box
Follow the further steps to create a masked password in VBA:
Step 1: Press Alt+F11 in the Excel window to get the VBA window.
Step 2: Select Insert in the Ribbon tab of the VBA code window.

Step 3: Then click on UserForm to get the toolbox and user form.

Step 4: Select CommandButton from Toolbox.

And then drag it to the UserForm1 tab.

Step 5: Select TextBox from the toolbox and then drag it to UserForm1.

Step 6: Press F4 to get the Properties Window.
Step 7: Change the name of the Text Box to "txtPassword"

Step 8: Change the PasswordChar property of txtPassword to an asterisk (*) to mask the entered password.

Step 9: In the drop-down box select CommandButton1.

Step 10: Change the name of the CommandButton to CmdInput and Caption name to Submit.

Step 11: Change the caption name in the Properties - UserForm1 tab to Password.

Step 11: Double-click on Submit button of the Password form.

Step 12: Unload Me is used to close the form and remove its details from memory Now, to run the code press F5.
Step 13: Enter your password, which will stay hidden in the UserForm window.

Step 14: Click the Submit button to display the password in a message box.
