Microsoft Office Tutorials and References
In Depth Information
Chapter 12: Custom Dialog Box Alternatives
The two examples in this section are available on the companion CD-ROM. The file is
named VBA inputbox.xlsm .
The Excel InputBox method
Using Excel’s InputBox method offers three advantages over VBA’s InputBox function:
h You can specify the data type returned.
h The user can specify a worksheet range by dragging in the worksheet.
h Input validation is performed automatically.
The syntax for the Excel InputBox method is
InputBox(Prompt [,Title][,Default][,Left][,Top][,HelpFile, HelpContextID]
[,Type])
h Prompt : Required. The text displayed in the input box.
h Title : Optional. The caption in the input box window.
h Default : Optional. The default value to be returned by the function if the user enters
nothing.
h Left , Top : Optional. The screen coordinates of the upper-left corner of the window.
h HelpFile , HelpContextID : Optional. The Help file and Help topic.
h Type : Optional. A code for the data type returned, as listed in Table 12-1.
Table 12-1: Codes to Determine the Data Type Returned by Excel’s Inputbox Method
Code
Meaning
0
A formula
1
A number
2
A string (text)
4
A logical value (True or False)
8
A cell reference, as a range object
16
An error value, such as #N/A
64
An array of values
 
Search JabSto ::




Custom Search