+ Reply to Thread
Results 1 to 6 of 6

mulitple IF statements

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    12-03-2008
    Location
    Cardiff
    MS-Off Ver
    2003
    Posts
    123

    mulitple IF statements

    I am trying to using multiple if staements regarding one cell.

    What I am trying to achieve is:

    if b2=0, then null, however if b2=1, then arable, however if b2=2, then manged grassland, however if b2=3, then forestry/woodland, however if b2=4, then semi-natural vegetation, however if b2=5, then urban, however if b2=6, then water

    I have these 2, but they don't work - what am i doing wrong?

    =IF(B2=0,null, IF(B2=1, Arable, IF(B2=2, Managed_Grassland, IF(B2=3, Forestry/Woodland, IF(B2=4, Semi-natural_Vegetation, IF(B2=5, Urban, IF(B2=6, Water, NO_LAND_USE)))))))

    =IF(B2=0,IF(B2=1,IF(B2=2,IF(B2=3, IF(B2=4,IF(B2=5, IF(B2=6, Water, null), Urban),Semi-natural_Vegetation), Forestry/Woodland), Maneged_grassland), Arable), null)

    Cheers
    Last edited by Back2Basics; 12-05-2008 at 06:20 AM.

  2. #2
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326
    You can start with this kind of formula :
    =LOOKUP(b2,{0,1,2,3},{0,"arable","manged","forestry"}) and extend the ranges

    If you don't want to hard code make a small table with the values in col1 and the results in col 2 and replace the values between braces with the ranges

  3. #3
    Forum Contributor
    Join Date
    12-03-2008
    Location
    Cardiff
    MS-Off Ver
    2003
    Posts
    123
    Thanks again Arthur, you gave me a great solution yesterday as well.

    Cheers, very thankful!

  4. #4
    Forum Contributor mewingkitty's Avatar
    Join Date
    09-29-2008
    Location
    Fort McMurray, Alberta, Canada
    MS-Off Ver
    Excel 2003
    Posts
    949

    Hm,

    I'd go with a table and vlookup, but that's just me. I used to use if statements the same way you suggested initially, they get overly-cluttered fast though.
    Last edited by mewingkitty; 12-15-2008 at 01:46 PM.

  5. #5
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320
    in answer to your original question

    =IF(B2=0,null, IF(B2=1, Arable, IF(B2=2, Managed_Grassland, IF(B2=3, Forestry/Woodland, IF(B2=4, Semi-natural_Vegetation, IF(B2=5, Urban, IF(B2=6, Water, NO_LAND_USE)))))))
    what you are doing wrong is not enclosing text in quotes!
    =IF(B2=0,"null", IF(B2=1, "Arable", IF(B2=2, "Managed_Grassland", IF(B2=3, "Forestry/Woodland", IF(B2=4, "Semi-natural_Vegetation", IF(B2=5, "Urban", IF(B2=6, "Water", "NO_LAND_USE")))))))

  6. #6
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326
    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