Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing an IF statement in Excel 1

Status
Not open for further replies.

Excelerate2004

Programmer
Mar 8, 2004
163
CA
How can I write this in excel?

IF (C2>D2 AND C2>E2 AND C2>F2) Then "A"
ELSEIF (D2>C2 AND D2>E2 AND D2>F2)Then "T"
ELSEIF (E2>C2 AND E2>D2 AND E2>F2) Then "G"
ELSEIF (F2>C2 AND F2>D2 AND F2>E2) Then "C"
END IF

I keep getting caught up on the brackets!!
 
The syntax works like this:

[COLOR=blue white]=if(and(C2>D2, C2>E2, C2>F2),"A",if(and(D2>C2, D2>E2, D2>F2), "T", if(and(E2>C2, E2>D2, E2>F2), "G", if(and(F2>C2, F2>D2, F2>E2),"C"))))[/color]

[tt]_____
[blue]-John[/blue]
[/tt][red]Quidquid latine dictum sit, altum viditur[/red]

Help us help you. Please read FAQ181-2886 before posting.
 


=IF(AND(C2>D2,C2>E2,C2>F2),"A",AND(D2>C2,D2>E2,D2>F2),"T",AND(E2>C2,E2>D2,E2>F2),"G",AND(F2>C2,F2>D2,F2>E2),"C","")

[Blue]Blue[/Blue] [Dragon]

If I wasn't Blue, I would just be a Dragon...
 
Forgot the additional IF's:

=IF(AND(C2>D2,C2>E2,C2>F2),"A",IF(AND(D2>C2,D2>E2,D2>F2),"T",IF(AND(E2>C2,E2>D2,E2>F2),"G",IF(AND(F2>C2,F2>D2,F2>E2),"C",""))))

[Blue]Blue[/Blue] [Dragon]

If I wasn't Blue, I would just be a Dragon...
 
You could drop the ANDs and make it a little more compact:

=IF(MAX(C2:F2)=C2,"A",IF(MAX(C2:F2)=D2,"T",IF(MAX(C2:F2)=E2,"G",IF(MAX(C2:F2)=F2,"C"))))

[tt]_____
[blue]-John[/blue]
[/tt][red]Quidquid latine dictum sit, altum viditur[/red]

Help us help you. Please read FAQ181-2886 before posting.
 
bluedragon2 said:
Forgot the additional IF's
When I read your first post, I thought I was about to learn something new. [smile]

[tt]_____
[blue]-John[/blue]
[/tt][red]Quidquid latine dictum sit, altum viditur[/red]

Help us help you. Please read FAQ181-2886 before posting.
 
Glad to help.
[cheers]

[tt]_____
[blue]-John[/blue]
[/tt][red]Quidquid latine dictum sit, altum viditur[/red]

Help us help you. Please read FAQ181-2886 before posting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top