IF Statements

M

mlynn

I am trying to write a funciton with several IF statements and it is not
working. This is to test one cell with all the statements. ie. Say we are
using cell A2,

If cell A2 is 48 it would enter a 1, if cell A2 is 49-54 it would enter a 2,
if cell A2 is 55-60 it would enter a 3, or if cell A2 is greater than 60 it
would enter a 5, otherwise it would enter a 0 if it does not meet any of the
above criteria.

I have tried several if statements and can get part of it to work but not
the entire thing. Can you help me write the function?

Thank you!
 
J

JudithJubilee

Hi Mylnn,

Try this:

=IF(A2>60,5,IF(A2>=55,3,IF(A2>=49,2,IF(A2=48,1,0))))

You need to start from the largest number.

Judith
 
D

Don Guillett

Using IF, modify to suit. Start at the top

=IF(D6>20,3,IF(D6>10,2,IF(D6>0,1,"")))
 
G

Gary''s Student

You don't need any IFs:

=(A2=48)*1+(A2>48)*(A2<55)*2+(A2>54)*(A2<61)*3+(A2>60)*5
 
M

Mike H

Hi,

=LOOKUP(A2,{-999999,48,49,55,61},{0,1,2,3,5})


--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.
 
D

David Biddulph

Sorry, missed a condition
=IF(A2=48,1,IF(AND(A2>=49,A2<=54),2,IF(AND(A2>=55,A2<=60),3,IF(A2>60,5,0))))

If you didn't have the ranges from 48 to 49, and from 54 to 55, where you
say you want 0, it would have been simpler.
 
D

David Biddulph

That depends on what values you think the OP wants for A2 values such as
48.5 or 54.5. Your guess may well be right, but ...
 
M

mlynn

Thank you Judith this solved my problem.

JudithJubilee said:
Hi Mylnn,

Try this:

=IF(A2>60,5,IF(A2>=55,3,IF(A2>=49,2,IF(A2=48,1,0))))

You need to start from the largest number.

Judith
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top