View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
L. Howard L. Howard is offline
external usenet poster
 
Posts: 852
Default Cancel Input Box error

On Thursday, October 23, 2014 12:33:21 AM UTC-7, GS wrote:
Thanks for the nudge, Claus.

Got it to work using this.

Regards,
Howard


sNum = InputBox("Pick no more than " & vbCr & _
" " & rngFnd.Offset(, 6) & " Stocks" & vbCr & "for
Código I: " & myFnd & _ " Quantidade Retirada in Cell F10")

If sNum = "" Then
[F6,F8,F10,J10].ClearContents
Exit Sub
ElseIf sNum = False Then
[F6,F8,F10,J10].ClearContents
'MsgBox "You canceled"
Exit Sub
End If


This is still using VB's InputBox and so the 'EldeIf' will raise an
"Invalid procedure call or argument" error! Otherwise, 'If sNum = ""'
means user cancelled the InputBox. This would be the case even if text
was entered but the OK button not clicked!

--
Garry


The tests I did was to click the red "X", click OK (with no entry) and click Cancel (with no entry).

I got no errors. When entries are made they work also.

So do I have more error checking code than needed?

Howard