VBAString Tip 3: How To Make An Input Box In Excel VBA


This post will use VBA to show you how to display whatever a user enters in an input box.

For example, if a user enters “123456789”, the output should be “account# 123456789 is available”.

First, add a button to your worksheet and input this VBA code behind it:

Sub Button1_Click()
    
    Dim strInput As String
    Dim strTextStart As String
    Dim strTextEnd As String
    
    strTextStart = "account# "
    strTextEnd = " is available"
    
    strInput = InputBox("Enter desired account number", "Account Number", 0)
    
    MsgBox strTextStart & strInput & strTextEnd
    

End Sub

Watch this:

Let me know if you have any questions

[simple_contact_form]

****************************************************