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]
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
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
A formula
A number
A string (text)
A logical value (True or False)
A cell reference, as a range object
An error value, such as #N/A
An array of values
Search JabSto ::

Custom Search