You must always also test the type of the variable to be boolean: VarType(varInput) = vbBoolean
when using the Application.InputBox
.
Dim varInput As Variant
varInput = Application.InputBox("Text", "Title", Type:=2)
If VarType(varInput) = vbBoolean And varInput = False Then
Exit Sub
End If
If you test only for False
…
If varInput = False Then
… then it will also exit sub if you enter 0
or Falsch
(in german Excel) or False
(in English Excel).
This hapens because a string of 0
or "Falsch"
(or "False"
) automatically casts into a boolean if compared with False
. But only the Cancel button returns a true boolean.