Nested IF Troubles

  • Thread starter Thread starter Dell
  • Start date Start date
D

Dell

I am trying to figure this nested if statment out but continue to get
errors there are too many arguments. Here is what I am attempting: (simple
blackjack game)

If Player 1 =<21 but > than Player 2 Player 1 wins; otherwise, If Player 2 <
21 but > Player 2, Player 2 wins.... yup thats the way I feel.

Please help shed some light on the subject...thanks again for all your help
 
how about =if(and(player1<=21,player1>player2)=true,"player
wins",if(and(player2<=21,player2>player1)=true,"player 2 wins","tie")
 
Here's another set-up to play around with ..

Suppose you have in cols A and B
headers in row1, data in row2 down

Player1 Player2 Winner
20_____19_____?
12_____16_____?
13_____13_____?
etc

Put in C2:

=IF(OR(A2="",B2=""),"",IF(OR(AND(A2>21,B2>21),AND(A2=B2)),"Draw",IF(AND(A2>2
1,B2<21),B$1,IF(AND(A2<21,B2>21),A$1,OFFSET($A$1,,MATCH(MAX(A2:B2),A2:B2,0)-
1)))))

Copy C2 down as many rows as desired

Col C will return the outcome of each round of the game

For the sample data, it'll show as:

Player1 Player2 Winner
20_____19____Player1
12_____16____Player2
13_____13____Draw

--
And instead of the labels "Player1", "Player2" in A1:B1
you could enter the actual names .. Have fun !
--
Rgds
Max
xl 97
---
Please respond in thread
xdemechanik <at>yahoo<dot>com
----
Dell said:
I am trying to figure this nested if statment out but continue to get
errors there are too many arguments. Here is what I am attempting: (simple
blackjack game)

If Player 1 =<21 but > than Player 2 Player 1 wins; otherwise, If Player 2 <
21 but > Player 2, Player 2 wins.... yup thats the way I feel.

Please help shed some light on the subject...thanks again for all your
help
 
Oops, a correction for superfluousness ..:

"AND(A2=B2)" in the formula for C2
should read simply as : A2=B2

i.e., put instead in C2:

=IF(OR(A2="",B2=""),"",IF(OR(AND(A2>21,B2>21),A2=B2),"Draw",IF(AND(A2>21,B2<
21),B$1,IF(AND(A2<21,B2>21),A$1,OFFSET($A$1,,MATCH(MAX(A2:B2),A2:B2,0)-1))))
)
 
Max wrote...
Here's another set-up to play around with ..

Suppose you have in cols A and B headers in row1, data in row2 down

Player1 Player2 Winner
20_____19_____?
12_____16_____?
13_____13_____?
etc

Put in C2:

=IF(OR(A2="",B2=""),"",IF(OR(AND(A2>21,B2>21),
AND(A2=B2)),"Draw",IF(AND(A2>21,B2<21),B$1,
IF(AND(A2<21,B2>21),A$1,OFFSET($A$1,,
MATCH(MAX(A2:B2),A2:B2,0)-1)))))

Much, much too long, even given elimination of one AND call in you
follow-up. No need at all for OFFSET/MATCH.

IF(COUNT(A2:B2)<2,"",
CHOOSE(2-SIGN(MOD(MIN(22,A2),22)-MOD(MIN(22,B2),22)),
$A$1,"Draw",$B$1)
 
hgrove > said:
Much, much too long, even given elimination of one AND call in your
follow-up. No need at all for OFFSET/MATCH.

IF(COUNT(A2:B2)<2,"",
CHOOSE(2-SIGN(MOD(MIN(22,A2),22)-MOD(MIN(22,B2),22)),
$A$1,"Draw",$B$1))

Brilliant alternative ..
Thanks, Harlan !
 
Thanks mucho!
Max said:
Oops, a correction for superfluousness ..:

"AND(A2=B2)" in the formula for C2
should read simply as : A2=B2

i.e., put instead in C2:

=IF(OR(A2="",B2=""),"",IF(OR(AND(A2>21,B2>21),A2=B2),"Draw",IF(AND(A2>21,B2<
 
Back
Top