Chapter 2.3 - Input Box Function
Chapter 2.3 - Input Box Function
#1 Excel tutorial on the net Excel Introduction Basics Functions Data Analysis VBA 300 Examples Ask us
You can use the InputBox function in Excel VBA to prompt the user to enter a value. Place a command button on
your worksheet and add the following code lines: Chapter < >
1. First, declare the variable myValue of type Variant. MsgBox
Dim myValue As Variant
Note: we use a variable of type Variant here because a Variant variable can hold any type of value. This way the Learn more, it's easy
user can enter text, numbers, etc.
MsgBox Function
InputBox Function
Range("A1").Value = myValue
Result when the user enters the value 5 and clicks the OK button.
4. The InputBox function has more optional arguments. The following code line shows an input box with a title
displayed in the title bar and has a default value. The default value will be used if no other input is provided.
Note: Place your cursor on InputBox in the Visual Basic Editor and click F1 for help on the other optional
arguments.
EXCEL EASY • FREE EXCEL HELP • COPYRIGHT (C) 20102017 • ALL RIGHTS RESERVED
MICROSOFT EXCEL TUTORIAL | HOW TO USE VBA | EXCEL FORMULAS | DROPDOWN LIST