Entering basic types
option explicit
sub main() ' {
dim num as double
dim txt as string
dim bol as boolean
num = application.inputBox("Enter a number" , "Example", type := 1) : debug.print("num = " & num)
txt = application.inputBox("Enter a string" , "Example", type := 2) : debug.print("txt = " & txt)
bol = application.inputBox("Enter a boolean", "Example", type := 4) : debug.print("bol = " & bol)
end sub ' }
Entering ranges
With
type := 8
,
inputBox
lets the user enter a
range by selecting it with the mouse (and then process the range in the VBA code).
option explicit
sub main() ' {
dim rng as range
set rng = application.inputBox("Enter a range" , "Example", type := 8)
debug.print("The entered range is: " & rng.address)
end sub ' }