1

i have a code that ask for a password. i need to disable the exit button "X". here is the code i'm using:

Dim myInputBoxVariable As Variant
    myInputBoxVariable = Application.InputBox(Prompt:="", Title:="PLEASE ENTER PASSWORD", Default:="Enter Password Here")
        'MsgBox "Your input was: " & myInputBoxVariable
        If myInputBoxVariable = "False" Then
            Exit Sub
        End If
Byron
  • 61
  • 1
  • 11
  • 1
    You can't disable it, but you can loop while the input isn't valid. See [this question](https://stackoverflow.com/questions/26264814/how-to-detect-if-user-select-cancel-inputbox-vba-excel/26264885) for the right way to check if the user clicked Cancel. – BigBen Dec 05 '19 at 14:05
  • that helps. thanks BigBen – Byron Dec 05 '19 at 14:14
  • Depending on what is behind the restriction for this password box, you have a number of options rather than disable it. If it pops up when opening a file for example, you could have the file close itself if the correct password is given. Same for when it pops up by selecting a different sheet, move to another sheet if an incorrect password is given. I would normally treat clicking `Exit` or `X` as an incorrect answer, and have the same behaviour apply, but skip any messages saying "wrong answer". – Plutian Dec 05 '19 at 14:31

0 Answers0