+ Reply to Thread
Results 1 to 6 of 6

fill cell with info from other cells using IF statement

  1. #1
    Registered User
    Join Date
    02-03-2012
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    25

    fill cell with info from other cells using IF statement

    Hi, all. I've created what I thought would be a simple IF statement based on a couple others I found on this site but I'm having trouble getting it to work properly past the second or third "IF". My goal is to fill in one cell (in column D) based on the info in three other cells in the same row (columns A, B and C).

    If A2 is not equal to 0, insert the data from A2.
    If A2 IS equal to 0, insert the data from B2.
    If B2 is equal to 0, insert the data from C2.
    If C2 is equal to 0, insert the word "none".

    If it's easier, I can do it this way instead (I'd prefer to use the zeroes, though):

    If A2 is not empty, insert the data from A2.
    If A2 IS empty, insert the data from B2.
    If B2 is empty, insert the data from C2.
    If C2 is empty, insert the word "none".

    These are the two formulas I've been working with.

    =IF(A2<>0,A2,IF(A2=0,B2,IF(B2=0,C2,IF(C2=0,"none"))))

    =IF(A2<>"",A2,IF(A2="",B2,IF(B2="",C2,IF(C2="","none"))))

    The first two IFs work, but when it gets to C, it stops working and just shows a zero. Am I even close to getting the statements correct? Any help is appreciated.

    Thanks,
    Angie

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: fill cell with info from other cells using IF statement

    IF statements work from left to right, and the function stops as soon as a TRUE result occurs. So if the C part is not working, it might be because one or more of the previous conditions have already been met.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: fill cell with info from other cells using IF statement

    Hi Angie,

    but when it gets to C, it stops working and just shows a zero.
    How.. ? can you show a sample workbook? thanks.

    Regards,
    DILIPandey

    <click on below 'star' if this helps>
    DILIPandey, Excel rMVP
    +919810929744 (India), +971528225509 (Dubai), [email protected]

  4. #4
    Registered User
    Join Date
    02-03-2012
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: fill cell with info from other cells using IF statement

    My apologies to both of you for not thinking to include what actually wasn't working. I should have said that if A1 or B1 are not equal to 0, the correct data is being filled in. If B1 is equal to 0, it does not fill in data from C1. And if C1 is equal to 0, it does not fill in "none" (if that last one doesn't work it isn't the end of the world -- I can live with just the zero).

    I'm not sure how to insert a spreadsheet like I've seen others do, so I'm attaching a copy, if that's okay. test_file.xlsx

  5. #5
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: fill cell with info from other cells using IF statement

    The first part of your formula: =IF(A2<>0,A2,IF(A2=0,B2, forces a stop here... because A2 is always going to be not equal to it will be equal to 0... so you will always get either A2 or B2 value as a result.

    Try:

    =IF(A2=0,IF(B2=0,IF(C2=0,"none",C2),B2),A2)

  6. #6
    Registered User
    Join Date
    02-03-2012
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: fill cell with info from other cells using IF statement

    That worked perfectly. Thanks so much for helping me!

+ 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