April 2006
Beginner
1114 pages
98h 16m
English
[Application.]InputBox(Prompt, [Title], [Default], [Left], [Top], [HelpFile], [HelpContextID], [Type])
This is the same as the Visual Basic InputBox method with one addition: Application.InputBox allows you to get a selected range using the Type argument which accepts the settings in the following table:
|
Setting |
Input is |
|---|---|
|
0 |
A formula |
|
1 |
A number |
|
2 |
Text (a string) |
|
4 |
A logical value (True or False) |
|
8 |
A cell reference, as a |
|
16 |
An error value, such as #N/A |
|
64 |
An array of values |
The following code demonstrates getting a range using InputBox:
Sub TestInputBox( )
Dim rng As Range
On Error Resume Next
Set rng = Application.InputBox( _
"Select a cell", , , , , , , 8)
If Not (rng Is Nothing) Then
Debug.Print rng.Count & " cells selected."
Else
Debug.Print "Input cancelled."
End If
End SubSee Chapter 3 for details on the Visual Basic InputBox method.
Read now
Unlock full access