English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I'm trying to use IF statements in Excel but I can't get round the problem of using more than 7. I want to use 52 statements as I'm trying to apply it to playing card data:
IF(A1=0, "Ac")
IF(A1=1,"2c")
"
"
"
IF(A1=51,"Ks")

Has anyone got any tips?

Cheers

2007-03-16 06:34:46 · 6 answers · asked by lcam 1 in Computers & Internet Programming & Design

Found the solution now thanks

=IF(A2>25, CHOOSE(A2-25,"Ah","2h","3h","4h","5h","6h","7h","8h","9h","Th","Jh","Qh","Kh","As","2s","3s","4s","5s","6s","7s","8s","9s","Ts","Js","Qs","Ks"), CHOOSE(A2+1,"Ac","2c","3c","4c","5c","6c","7c","8c","9c","Tc","Jc","Qc","Kc","Ad","2d","3d","4d","5d","6d","7d","8d","9d","Td","Jd","Qd","Kd"))

2007-03-16 20:44:31 · update #1

6 answers

It looks like you're trying to randomly sort (shuffle) a deck of cards. Here's how I do it.

1) Starting with A1 and going through A52, I name the 52 cards. This can be full names, or abreviations.

2) In B1 through B52, I have this formula:
=RAND()

3) In C1 through C52, I have this formula:
=INDEX(A$1:A$52,RANK (B1,B$1:B$52),1)

C1 through C52 will randomly sort the 52 cards every time the sheet is recalculated. If you want to set the deck in a random order, you can copy these cells and paste special (values) into another column.

2007-03-16 10:08:59 · answer #1 · answered by nospamcwt 5 · 0 0

Instead of using IF function, try the VLOOKUP function (or you can use HLOOKUP function, if you prefer)

Assume you've kept the values 1, 2 upto 52 numbers in E1 to E52 and Ac, 2c upto Ks in F1:F52. Then you can write the following formula in B1
to get your desired result
= VLOOKUP(A1, $E$1:$F$52, 2, FALSE)

Hope this will do.

2007-03-16 06:48:42 · answer #2 · answered by Murali 1 · 0 0

Check out the Vertical Lookup (VLOOKUP) Function. Since you've figured out IF statements, I won't insult you with a full explaination--Help describes it well.

Basically, you make a table with the numbers 1-52 in a column, and the names of the cards in a second column. Then you have the function look up the number (i.e. "2") and it will look in the column to the right of it to return the value "2 clubs".

2007-03-16 06:39:58 · answer #3 · answered by wayfaroutthere 7 · 0 0

In excel the maximum no. of possible looped If's is 7.

2007-03-16 06:41:42 · answer #4 · answered by Jacksonjosekunnel 3 · 0 0

use VBA and use a CASE statement.
http://www.ozgrid.com/VBA/select-case.htm

press ALT+F11 to pull up the visual basic editor and type in the code on that page.
or you can go to Tools>Macro>Visual Basic Editor

2007-03-16 06:48:44 · answer #5 · answered by BigJohnny 4 · 0 0

even in spite of the shown fact that, in case you choose extra suitable than one IF fact, that announces IF this, yet no longer that, yet whilst some thing else, you may do a nested IF fact. occasion: IF(A1>B1,"confident",IF(A1

2016-10-02 05:44:24 · answer #6 · answered by bachmann 4 · 0 0

fedest.com, questions and answers