If you use the application input box then you could test for a cancel or X click as follows:
Sub Test()
i = Application.InputBox("Enter number")
if i = False then
MsgBox "User cancelled"
elseif len(i) = 0 then
Msgbox "Nothing entered"
else
MsgBox "Something entered"
End If
End Sub
If you don't want to use the application inputbox you can achieve the same as follows:
Sub Test2()
i = InputBox("Enter number")
if (StrPtr(i) = 0&) then
MsgBox "User cancelled"
elseif len(i) = 0 then
Msgbox "Nothing entered"
else
MsgBox "Something entered"
End If
End Sub
Bookmarks