+ Reply to Thread
Results 1 to 6 of 6

forming an IF statement function

  1. #1
    Registered User
    Join Date
    01-01-2009
    Location
    beirut
    MS-Off Ver
    Excel 2007
    Posts
    5

    forming an IF statement function

    Writing a single nested IF statement function to calculate the grades of the students the following rules:

    If the student grade is His/her letter grade is
    Greater or equal to 90: A
    Greater or equal to 80 and less then 90: B
    Greater or equal to 70 and less then 80: C
    Greater or equal to 60 and less then 70: D
    Any other grade: F

    thanks
    Last edited by Tony_t; 01-01-2009 at 10:34 AM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531
    Rather than use embedded Ifs you will be better off using a LOOKUP, eg

    =LOOKUP(A1,{0,60,70,80,90},{"F","D","C","B","A"})

    Where A1 holds grade.

  3. #3
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Maybe

    =IF(A1="","",LOOKUP(A1,{0,60,70,80,90},{"F","D","C","B","A"}))
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531
    If we're adding safety clauses with given LOOKUP better to check value is both numeric and > 0, no ?

    =IF(ISNUMBER(A1),IF(A1>=0,LOOKUP(A1,{0,60,70,80,90},{"F","D","C","B","A"}),""),"")

    If using XL07 you could just use

    =IFERROR(LOOKUP(A1,{0,60,70,80,90},{"F","D","C","B","A"}),"")

  5. #5
    Registered User
    Join Date
    01-01-2009
    Location
    beirut
    MS-Off Ver
    Excel 2007
    Posts
    5
    thx a lot DonkeyOte it worked fine

  6. #6
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    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

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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.6.0 RC 1