+ Reply to Thread
Results 1 to 6 of 6

Thread: if function

  1. #1
    Registered User
    Join Date
    05-31-2010
    Location
    Moree Australia
    MS-Off Ver
    Excel 2007
    Posts
    3

    Angry if function

    Can anyone help me with a formular to give me the following results for the following;

    if cell 1 contains a value between 0 and 18 then an "A" result is required.
    If cell 1 contains a value betweenl 19 and 26 then a "B" result is requied
    if cell 1 contains a value between 27 and 36 then a "C" result is required
    and if cell 1 contains a value of greater than 37 then a "D" result is required.

    IF(D3>0,D3<=18,A,IF(AND(D3>18,D3<=26,B,IF(AND(D3>27,D3<=36,C,IF(AND(D3>=37,D,)))))))

    This doesn't work for me, what am I doing wrong?

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    Excel 2007
    Posts
    6,219

    Re: if function

    First of all put "" around text.

    Second: no need for double check...

    Formula works as: IF function is TRUE then (something) ELSE (something else)

    so...

    IF(D3<=18, "A", IF(D3<=26, "B", IF( D3<=36, "C", "D")))

    Edit: notice that if number is greater than 18 (i.e. 25) it will go to second IF. Now, don't need to check again is it greater than 18. All you need is to see is it less or equal than 26.
    Last edited by zbor; 06-06-2010 at 02:52 AM.
    "Relax. What is mind? No matter. What is matter? Never mind!"

  3. #3
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    Excel 2007
    Posts
    6,219

    Re: if function

    Also...

    If cell is empty then you'll get A.
    If you want to avoid it you can add one more IF

    =IF(D3="", "", IF(D3<=18, "A", IF(D3<=26, "B", IF( D3<=36, "C", "D"))))
    "Relax. What is mind? No matter. What is matter? Never mind!"

  4. #4
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    Excel 2007
    Posts
    6,219

    Re: if function

    Another way:

    =LOOKUP(D3,{0,18,26,36},{"A","B","C","D"})

    Again:

    =IF(D3="", "", LOOKUP(D3,{0,18,26,36},{"A","B","C","D"}))

    Edit. which will give you error for negative results while prior will return A
    Last edited by zbor; 06-06-2010 at 03:00 AM.
    "Relax. What is mind? No matter. What is matter? Never mind!"

  5. #5
    Registered User
    Join Date
    05-31-2010
    Location
    Moree Australia
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: if function

    Many thanks Zbor

  6. #6
    Forum Guru, retired Admin royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    25,640

    Re: if function

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel Tips & Solutions, free examples and tutorials why not check out my downloads

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0