Hello,
I'm trying to use application.inputbox with nested if statement but something is going wrong.
So basically what I want done.
there will be a button on the spreadsheet that when pressed will run the macro. But I don't want just anyone to run the macro. so I want to make it password protected.
I'm trying to do this using an application.inputbox.
when the button is pressed the inputbox will popup asking for password, if correct password is pressed then the macro is executed. This part I'm able to do, the problem occurs when I try to add anymore to the if statement.
For example I'm trying to add that if incorrect password is entered so the inputbox pops up again that says incorrect password. and at this point I want them to be able to keep popping up until correct password is entered.
if I start using elseif statement than my cancel and close buttons don't work.
Here is the code I have so far.
Sub UserPasswordInput()
Dim userInput As String
userInput = Application.InputBox("Enter the Password to Generate Limits?")
If userInput = "password" Then
runs macro
Else: userInput = Application.InputBox("Incorrect Password")
If userInput = "password" Then
runs program
End If
End If
End Sub
this is where I left off, ive tried to play around inserting elseif and other options but non work.
with the code as it is now if the correct password is entered than macro runs.
and also if incorrect password is entered I get the other inputbox that says incorrect password.
problem here is when first inbox box pops up and no password is entered and if I press ok or cancel it takes me to the next inputbox that says "incorrect password"
So its someone annoying.
I want this to be just like any other password requiring inputbox.
where when asked for password the user can enter password or cancel. if wrong password is entered than it would prompt them that it was wrong and they can continue to try to enter the password or cancel at anytime.
I'm trying to use application.inputbox with nested if statement but something is going wrong.
So basically what I want done.
there will be a button on the spreadsheet that when pressed will run the macro. But I don't want just anyone to run the macro. so I want to make it password protected.
I'm trying to do this using an application.inputbox.
when the button is pressed the inputbox will popup asking for password, if correct password is pressed then the macro is executed. This part I'm able to do, the problem occurs when I try to add anymore to the if statement.
For example I'm trying to add that if incorrect password is entered so the inputbox pops up again that says incorrect password. and at this point I want them to be able to keep popping up until correct password is entered.
if I start using elseif statement than my cancel and close buttons don't work.
Here is the code I have so far.
Sub UserPasswordInput()
Dim userInput As String
userInput = Application.InputBox("Enter the Password to Generate Limits?")
If userInput = "password" Then
runs macro
Else: userInput = Application.InputBox("Incorrect Password")
If userInput = "password" Then
runs program
End If
End If
End Sub
this is where I left off, ive tried to play around inserting elseif and other options but non work.
with the code as it is now if the correct password is entered than macro runs.
and also if incorrect password is entered I get the other inputbox that says incorrect password.
problem here is when first inbox box pops up and no password is entered and if I press ok or cancel it takes me to the next inputbox that says "incorrect password"
So its someone annoying.
I want this to be just like any other password requiring inputbox.
where when asked for password the user can enter password or cancel. if wrong password is entered than it would prompt them that it was wrong and they can continue to try to enter the password or cancel at anytime.