Dear All,
I have boolean input box as I want code to only allow 0,1, True, False input only.
If nothing entered then Msgbox "Please try again" should appear.
Your help would be greatly appreciated.
Biz
I have boolean input box as I want code to only allow 0,1, True, False input only.
If nothing entered then Msgbox "Please try again" should appear.
VBA Code:
Sub Tests()
'// Vars
1 Dim blnAns As Boolean
'// Boolean prompt, 1 = true, 0 = false
2 blnAns = Application.inputbox(Prompt:="Do you want filter a particular item?" & vbCr & _
"1 = True, 0 = False", Title:="Filter List", Type:=4)
If StrPtr(blnAns) = 0 Then
MsgBox ("Cancel pressed!")
Exit Sub
End If
'~~> Check only 1 / True 0 / False as between entered
If Application.Sum((blnAns >= 0 And blnAns <= 1), (blnAns = "True" Or blnAns = "False")) > 0 Then
MsgBox "You have responded within range allowed :" & blnAns, vbInformation
Else
MsgBox "Please try again", vbCritical
Exit Sub
End If
End Sub
Your help would be greatly appreciated.
Biz