0% found this document useful (0 votes)
12 views2 pages

Chapter 2.3 - Input Box Function

The document discusses using the InputBox function in Excel VBA to prompt users to enter values. It provides code examples of using InputBox to display a prompt, retrieve the user input, and write it to a cell. It also shows how to set the title and default value for the input box.

Uploaded by

putra.stat11
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views2 pages

Chapter 2.3 - Input Box Function

The document discusses using the InputBox function in Excel VBA to prompt users to enter values. It provides code examples of using InputBox to display a prompt, retrieve the user input, and write it to a cell. It also shows how to set the title and default value for the input box.

Uploaded by

putra.stat11
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Excel Easy

#1 Excel tutorial on the net Excel Introduction Basics Functions Data Analysis VBA 300 Examples Ask us

InputBox Function Search Entire Site Go

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

Download Excel File


inputbox­function.xls

Follow Excel Easy

2. Add the following code line to show the input box.

myValue = InputBox("Give me some input")

3. Write the value of myValue to cell A1.

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.

myValue = InputBox("Give me some input", "Hi", 1)


Result when the user only clicks the OK button.

Note: Place your cursor on InputBox in the Visual Basic Editor and click F1 for help on the other optional
arguments.

3/3 Completed! Learn much more about msgboxes >


Back to Top: InputBox Function | Go to Next Chapter: Workbook and Worksheet Object

EXCEL EASY • FREE EXCEL HELP • COPYRIGHT (C) 2010­2017 • ALL RIGHTS RESERVED
MICROSOFT EXCEL TUTORIAL | HOW TO USE VBA | EXCEL FORMULAS | DROP­DOWN LIST

You might also like