Open In App

How to Mask Password in VBA Excel Input Box?

Last Updated : 23 Jan, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

A combination of integers, strings of characters, or other symbols is used to verify the identity of a user during the authentication process so, that they can access the system. But a password should always remain in a hidden format to prevent it from shoulder spying. Shoulder spying is a practice where a person collects our personal data by spying over our shoulders in Cyber Cafe or ATM. Let’s learn how to hide the password for that we need to mask the password in Excel Input Box.

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.

Selecting-insert

 

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

Clicking-on-userform

 

Step 4: Select CommandButton from Toolbox.

selecting-command-button

 

And then drag it to the UserForm1 tab.

Dragging-to-userform-1-tab

 

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

selecting-testbox

 

Step 6: Press F4 to get the Properties Window.

Step 7: Change the name of the Text Box to “txtPassword”

Changing-name-of-textbox

 

Step 8: Now, scroll down the Properties tab of txtPassword to assign a value of asterisk(*) in PasswordChar to create a password mask.

Creating-password-mask

 

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

Selecting-commandbutton1

 

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

Changing-name-of-commandbutton

 

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

changing-caption-name

 

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

Clicking-submit

 

Step 12: Write the following code to see the password in the Message Box.

Code-to-see-password

 

Unload Me is used to close the form and remove its details from the memory. Now, to run the code press F5.

Step 13: Enter the password which will be hidden in the Excel window

entering-password

 

Step 14: Click on Submit button so that we can see the password in the message box

Clicking-submit

 


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads