View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default boolean variable?

It looks like Type:=4 return the text string "Boolean" if the Cancel button
is pressed, so you should be able to do your code this way...

MyVar = Application.InputBox(Prompt:= _
"Is this a font color?- True or False", Type:=4)
If MyVar = Boolean Then MyVar = False

You definitely do NOT want the Else condition you showed as that would
change a legitimately entered False answer to True.

--
Rick (MVP - Excel)


"Steve" wrote in message
...
Howdee all.
I have a macro that I've got a variable that presently requires either a
true, or false input.
This macro calls to another function, which only requires an input if the
element is true.
I'd like it to only require an input if the statement is true.

I just tried-

MyVar = Application.InputBox(Prompt:="Is this a font color?- True or
False",
Type:=4)

If MyVar= "" Then
MyVar = False
Else: MyVar = True
End If

I receive a type mismatch error when I do this.