View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default Avoiding error on Input Box - if no value is entered

Sorry about the first post, ignore it. Try:

Sub qwerty()
x = InputBox(prompt:="feed me")
MsgBox (x)
x = Application.InputBox(prompt:="feed me")
MsgBox (x)
End Sub

The first call will return a null string.
The second call will retrun FALSE.

So MyData must be Dim'ed to handle the null string.
--
Gary''s Student - gsnu200849


"dhstein" wrote:

I have a line like this:

MyData = InputBox(Prompt:="Enter Data", Title:="ENTER Data")

If the user selects "Cancel", I get a Run-time error 13 - Type Mismatch.
How can I avoid this error when the user selects cancel ? Thanks for any
help on this.