Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excel VBA Input box

Tags:

excel

vba

I have following Input box for excel file. I don't want to show typing characters and need to show input box characters * , how to do this?

Private Sub Workbook_Open()

Dim UserName As String

UserName = InputBox("Please Enter Your USER NAME.")

Range("O1") = UCase(UserName)


End Sub

Thanks, Hewage

like image 469
Hewage Avatar asked Jan 28 '15 10:01

Hewage


People also ask

How do I add an input box in Excel VBA?

How to use Input Box in a VBA Code. Type “InputBox” and enter a space and you will get a tool for the arguments you need to define. Specify the “Prompt”, message that you want to show to the user. Define a title for the input box, otherwise, it will show the default title.

How do you make an input box with multiple inputs in Excel using VBA?

Creates an input box containing multiple lines (Create Excel VBA InputBox” & vbNewLine & “with multiple lines) with the InputBox function. Assigns the value returned by the InputBox function to a variable (myInputBoxMultipleLinesVariable = inputBox(…)). Displays a message box with the value held by the variable.

What does input () do in VBA?

Input is a function in VBA that is used to read the files whether it is opened in binary or input mode. The result of this function is a string that returns the contents of the file.


1 Answers

Use a UserForm Create a userform that has a Textbox, and Two Buttons In the textbox Properties, enter * in the PasswordChar Box

enter image description here

Use the code below in the userForm module.

Private Sub CommandButton1_Click()

If TextBox1 = "123456" Then
MsgBox "Correct"
Else
MsgBox "Incorrect"
End If
Unload Me

End Sub

Private Sub CommandButton2_Click()

'cancel button

Unload Me
End Sub

Private Sub UserForm_Initialize()

Me.Caption = "Enter Password"

End Sub

Your userform will look like this

enter image description here

like image 113
Davesexcel Avatar answered Sep 20 '22 23:09

Davesexcel