http://support.microsoft.com/?kbid=142141
you need to be using application.InputBox instead of just InputBox
Die_Another_Day
Dim S As String
S = InputBox("enter sometime")
If S = "" Then
Debug.Print "no input"
Exit Sub
Else
Debug.Print S
End If
This will not distinguish between the user pressing cancel and
the user pressing Enter with an empty input box. If you *really*
need to test for the Cancel key, use code like
Dim S As String
S = InputBox("enter something")
If StrPtr(S) = 0 Then
Debug.Print "user clicked cancel"
Else
Debug.Print "user click OK " & S
End If
--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
"Mike" <Mi...@discussions.microsoft.com> wrote in message
news:4D89A74E-56AE-4400...@microsoft.com...
sub test
dim strRet as string
strRet=inputbox("What would you like me to echo back?")
if len(strRet) =0 then
exit sub
else
msgbox "You asked me to echo:" & strRet
end if
end sub
"Mike" <Mi...@discussions.microsoft.com> wrote in message
news:4D89A74E-56AE-4400...@microsoft.com...
Sub iBox()
Dim var1 As Variant
var1 = Application.InputBox("Enter Text", "Testing Cancel Button")
If var1 = "False" Then
MsgBox "You Clicked Cancel"
Exit Sub
Else
MsgBox "You typed " & var1
End If
End Sub
Die_Another_Day
Dim vNumber
Dim dNumber As Double
vNumber = Application.InputBox(Prompt:="Put a number in the box",
Type:=1)
If vNumber = "False" Then
Exit Sub
Else
dNumber = Val(vNumber)
MsgBox dNumber
End If
End Sub
RBS
"Mike" <Mi...@discussions.microsoft.com> wrote in message
news:4D89A74E-56AE-4400...@microsoft.com...
--
Regards,
Tom Ogilvy
' See if Cancel was pressed.
If Response = "" Then
' If Cancel was pressed,
' break out of the loop.
Show_Box = False
--
Regards,
Tom Ogilvy
Die_Another_Day
Dim strInput As String
strInput = InputBox("do something")
If Len(strInput) = 0 Then
If StrPtr(strInput) = 0 Then
MsgBox "The user clicked Cancel"
Else
MsgBox "The user clicked Enter, but typed nothing"
End If
End If
--
Regards,
Tom Ogilvy