For Application.Inputbox if the result is FALSE it was cancelled. However if
the result is the word False it's treated the same as a cancel.
Dim v As Variant
v = Application.InputBox("enter a value")
If v = False Then
MsgBox "cancelled or typed in False"
Else
MsgBox "typed in : " & v & " (but can never display the typed-in
value of 'false' here)"
End If
Another way to do it is to use the regular Inputbox, and use the
little-known function StrPtr.
Dim s As String
s = InputBox("enter a value")
If StrPtr(s) = 0 Then
MsgBox "cancelled"
Else
MsgBox "Typed in : " & s
End If
--
Tim Zych
www.higherdata.com
Compare data in worksheets and find differences with Workbook Compare
A free, powerful, flexible Excel utility
"Chris D" wrote in message
...
For the following script I get an inputbox for which the user has to enter
a
number:
Dim result As Long
result = Application.InputBox("Enter Number of Days which are in this
report( highest number of worksheets in document", "Days in Report")
Select Case result
Case 1
Columns("T:CJ").Select
Case 2
Columns("U:CJ").Select
Case 3
Columns("V:CJ").Select
Case Else
MsgBox "please enter a valid number"
End Select
I would like the macro to exit the sub when "cancel" is selected.
Can anyone help me with this?