ANDstORy

Prosenjit Banerjee

New Member
Joined
Mar 19, 2002
Messages
19
Dear Sir,

If I write a statement like the following:

var = False AND msgbox("ANDstORy")

or a statement like the following:

val = True OR msgbox("ANDstORy")

in each case the outcome is a MessageBox conting the given message.

My question is, is not it a but of VB/VBA handling with the AND and OR operators? Or am I going wrong? Please show me a light. Because in some cases I have no other way besides writing an If-Else ladder with so many indents. Even I am quite wondered to see that the Iif() function also does not work as expected. It works like the same as stated above. i.e. the following statement:

var = Iif(True, 1, msgbox("ANDstORy"))

also shows the MessageBox containing the the given messages. What is going on? If it is a but then why Microsoft is not going to rectify it? If I am going wrong then please explain why?

Thanks.
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
I don't claim to be an expert at this sort of thing and I could well be misunderstanding you, but I'm not sure that you're using the AND/OR statements correctly. I've only seen them used in conjuction with some kind of logical test ie IF (logical test) AND/OR (logical test) THEN...

The Iif() problem I think is due to excel always evaluating both parts of the statement, even though it only needs one - I belive this is why your msgbox is appearing even though it is on the False part of the expression.
 
Upvote 0

Forum statistics

Threads
1,214,561
Messages
6,120,234
Members
448,951
Latest member
jennlynn

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top