VBA InputBox – Get Input from a User

Associated Files Download Links

VBA InputBox

The VBA InputBox allows you to prompt the user to input information.  That information is assigned to a variable and can be used in your code.

Here is how you can create an InputBox:

vba inputbox

Notice first we declare a variable. This variable will be assigned the value that the user enters.  We used variable type Variant so the InputBox can accept any type of value.

Get Input from a User

Here is another example using the most popular features of an InputBox.


The following code does three things:

1. Prompts for input with an InputBox and assigns it to a variable

2. Verify’s input, otherwise exits

3. Returns the input in a message box


VBA Coding Made Easy

Stop searching for VBA code online. Learn more about AutoMacro – A VBA Code Builder that allows beginners to code procedures from scratch with minimal coding knowledge and with many time-saving features for all users!

alt text


Learn More!

<<Return to VBA Examples

Did you find this VBA tutorial useful? Then share it with your friends and colleagues:

You may also like some of this related content...

VBA allows you to choose a file to open using the Application.GetOpenFilename method. In this
This tutorial will cover how to use the VBA MsgBox Function to display messageboxes to
Line Break in a Message Box (msgbox) If you need to put a larger amount
Make Userform Transparent Tek-Tips has a nice post in their forums for making User Forms
Automate Excel
Left Menu Icon