How To Make An InputBox In VBA

The input box is a great way to retrieve and process input
from your user.

In the following example we’ll control program flow based on the
user’s input in the inputbox.

Your user will enter a text value and we will evaluate their answer
and send them in the right direction.

Sub InputboxVBA()
    Dim strAnswer As String
    
    strAnswer = InputBox("What is the password?", "Enter Password")
    
    Select Case strAnswer
        
        Case "P@ssword"
            MsgBox "Correct!  You can now use the program."
            
        Case Else
            
            MsgBox "Your password entry was incorrect"
            
    End Select
End Sub

 

Let me know if you have any questions on how to make this  InputBox in VBA




By the way, if you got or are getting value from the VBA information, please give me a tip, thanks!


These posts may help answer your question too...

How To Determine If A User Clicked The Cancel Button On VBA Input Box

In this post I am going to address the question: “How can I determine if a user clicked the cancel button on a VBA Input Box” I only need to check the length of the InputBox response. If the “Cancel” button was clicked, the variable containing the value of the InputBox will be zero. In […]

Previous Post

How To Search A String With The VBA Instr Function

Next Post

Bringing A 300+ Column Excel File Into Access