Thread: Cancel InputBox
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
smartin smartin is offline
external usenet poster
 
Posts: 915
Default Cancel InputBox

Alfredo_CPA wrote:
Hi,

Does anybody knows how to instruct VBA to diferentiate between a Cancel in
the InputBox and a cero entered in the impiut box? (excel 2003)
I have this code:
ElseIf myerrorvalue = False Then Exit Sub '(errorvalue is the result of the
inputbox)

VBA is taking a 0 (cero) value as False (just like if the user click the
cancel button) and exits the sub, but I need the code to keep going

Thanks


This code demonstrates how the input value is interpreted:

Sub IPBOX()
Dim a As Variant
a = InputBox("prompt")
If a = "" Then
Debug.Print "canceled or empty input"
Else
Debug.Print Val(a)
End If
End Sub