Sign in to follow this  
rpg_code_master

Excel Formula syntax error

Recommended Posts

I have this formula:- =IF(B4=8,IF(C4=4,"OK",IF(B4=8,IF(C4=0,"OK",$A$4),IF(B4=0,IF(C4=8,"OK",$A$4),$A$4)))),IF(B4=4,IF(C4=8,"OK",IF(B4=8,IF(C4=0,"OK",$A$4),IF(B4=0,IF(C4=8,"OK",$A$4),$A$4)))$A$4),$A$4) Can anybody please identify the syntax error(s)? I am stumped. Thank you.

Share this post


Link to post
Share on other sites
Conner McCloud    1135
On the off chance this isn't a joke, I'll take a stab at it. Been a while since I did anything even remotely complex with Excel, but a cursury glance reveals a missing comma [second to last $A$4]. Also, your initial IF statement only has a then, but no else. This is followed by two additional comma separated statements with a trailing parenthesis. I believe all three of these need remedied.

I suspect proper boolean logic would greatly simplify this equation, but without some clue as to what it is supposed to accomplish I can't suggest a way how.

CM

Share this post


Link to post
Share on other sites
This is the logic that I am trying to put into an Excel formula:-



if ( ( B4 == 4 && C4 == 8 ) ||
( B4 == 8 && C4 == 4 ) ||
( B4 == 8 && C4 == 0 ) ||
( B4 == 0 && C4 == 8 ) )
{
cout << “OK";
}
else
{
cout << “Error";
}





Thank you

Share this post


Link to post
Share on other sites
Conner McCloud    1135
Quote:
Original post by rpg_code_master
This is the logic that I am trying to put into an Excel formula:-

*** Source Snippet Removed ***

Thank you

Look into AND and OR. I believe both take an arbitrary number of arguments, so your new function should be similar to this:

=IF(OR(AND(B4=4,C4=8), AND(...), ...), "OK", "ERROR")

CM

Share this post


Link to post
Share on other sites
Thanks,

Here is the final formula just for pure reference:-

=IF(OR(AND(B4=4,C4=8),AND(B4=8,C4=4),AND(B4=8,C4=0),AND(B4=0,C4=8)),1,0)

Compare it to:-

=IF(B4=8,IF(C4=4,"OK",IF(B4=8,IF(C4=0,"OK",$A$4),IF(B4=0,IF(C4=8,"OK",$A$4),$A$4)))),IF(B4=4,IF(C4=8,"OK",IF(B4=8,IF(C4=0,"OK",$A$4),IF(B4=0,IF(C4=8,"OK",$A$4),$A$4)))$A$4),$A$4)

I wonder which is more efficient...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this