Hide or ***** what is being typed in an input box

daniels012

Well-known Member
Joined
Jan 13, 2005
Messages
5,219
Is there a way to enter this without seeing what is typed in?

If InputBox("Enter Password", "Password") <> pwd Then
MsgBox ("Incorrect Password!")
Exit Sub

It works well, it just shows in the input box what is being typed.
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
The code it has listed goes into a standard module. I have my code to open a password when a button is pressed. Do I need the code there with the button instead of a standard module?
 
Upvote 0
You can place the code in your button module or use a standard module and call it with your button code. I haven't looked closely at the code, so you may need to modify it some. I don't know.

lenze
 
Upvote 0
lenze and DominicB,
I used the one you suggested. It is Daniel Klann's code. It gives me a compile error when I try to add it to this code:
the areas in red below!
Private Sub CommandButton1_Click()

pwd = "ss12pass"

If InputBoxDK("Enter Password", "Password") <> pwd Then
MsgBox ("Incorrect Password!")
Exit Sub
Else

ActiveSheet.Unprotect

ActiveCell.Value = InputBox("Enter Time")
Selection.Locked = True
ActiveSheet.Protect

End If

End Sub
 
Upvote 0
Hello,

Which Excel version do you use?

Place the code in a standard module

Can you please try this one:

Code:
Option Explicit

Private Sub CommandButton1_Click()
Dim pwd As String
pwd = "test"
 If InputBoxDK("Enter Password", "Password") <> pwd Then
    MsgBox ("Incorrect Password!")
    Exit Sub
 Else
    ActiveSheet.Unprotect pwd
     With ActiveCell
        .Value = InputBox("Enter Time")
        .Locked = True
     End With
    ActiveSheet.Protect Password:=pwd
 End If
End Sub

With Excel 2003 it runs.
 
Upvote 0
Modified your code slightly and it seems to work.
Code:
Private Sub CommandButton1_Click()
     pwd = "ss12pass"
     Rspn = InputBoxDK("Enter Password", "Password")
     If Rspn <> pwd ThenMsgBox ("Incorrect Password!")
     Else
     ActiveSheet.Unprotect pwd
     ActiveCell.Value = InputBox("Enter Time")
     Selection.Locked = True
     ActiveSheet.Protect pwd
     End If
End Sub



Seems to work.

lenze
 
Upvote 0
Tried it... Still get a compile error. It's not recognizing the InputBoxDK name.

Maybe because I am using Excel 2000??
 
Upvote 0

Forum statistics

Threads
1,215,420
Messages
6,124,800
Members
449,189
Latest member
kristinh

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top