+ Reply to Thread
Results 1 to 10 of 10

Excel 2007 : If and Or Statement

  1. #1
    Forum Contributor
    Join Date
    10-16-2011
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    112

    If and Or Statement

    I am trying to get my if and or function to work but I am having problem

    If Col1 and Col2 are #N/A I want a 0 to show up

    If (Col1>=Col2,Col1,Col2)

    But this is the part that I can't get working

    If Col1 has a value but Col2 is #N/A I get a value of 0 with my function but I need the Col 1 value

    Also if Col2 has a value but Col1 is #N/A I need the Col2 value

    here is the function I am using

    =IF(OR(ISNA(A2),ISNA(B2)),0,IF(A2>=B2,A2,B2))


    Thanks for your help
    Attached Files Attached Files
    Last edited by Jerseynjphillypa; 04-11-2012 at 10:19 AM.

  2. #2
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: If and Or Statement

    Quote Originally Posted by Jerseynjphillypa View Post
    If Col1 and Col2 are #N/A I want a 0 to show up
    AND(ISNA(A2),ISNA(B2))

    Quote Originally Posted by Jerseynjphillypa View Post
    If Col1 has a value but Col2 is #N/A I get a value of 0 with my function but I need the Col 1 value

    Also if Col2 has a value but Col1 is #N/A I need the Col2 value

    =IF(AND(ISNA(A2),ISNA(B2)),0,IF(ISNA(A2),B2,A2))

    What happens if they are both not NA? Do you want the max?

    Try this:

    =MAX(NOT(ISNA(A2))*A2,NOT(ISNA(B2))*B2)

  3. #3
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: If and Or Statement

    how about
    =MAX(IFERROR(A2,0),IFERROR(B2,0))
    it just treats error values like 0

  4. #4
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: If and Or Statement

    Oops. I hadn't tested my formula.

    JosephP beat me to it:

    =MAX(IFERROR(A2,0),IFERROR(B2,0))


    IFERROR() is different than ISNA, though. Is there a specific reason you are testing for #N/A, or do you want to catch any error?

  5. #5
    Valued Forum Contributor
    Join Date
    02-09-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    1,055

    Re: If and Or Statement

    Hello..

    Try this one and check:

    =IF(AND(ISNA(A2),ISNA(B3)),0,IF(AND(ISNUMBER(A2),ISNA(B2)),A2,IF(AND(ISNA(A2),ISNUMBER(B2)),B2,IF(AND(ISNUMBER(A2),ISNUMBER(B2)),MAX(A2,B2),""))))
    Regards...
    Click *, if my suggestion helps you. Have a good day!!

  6. #6
    Forum Contributor
    Join Date
    10-16-2011
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    112

    Re: If and Or Statement

    Quote Originally Posted by Whizbang View Post
    AND(ISNA(A2),ISNA(B2))




    =IF(AND(ISNA(A2),ISNA(B2)),0,IF(ISNA(A2),B2,A2))

    What happens if they are both not NA? Do you want the max?

    Try this:

    =MAX(NOT(ISNA(A2))*A2,NOT(ISNA(B2))*B2)
    Yes I want the Max value if both are not NA

    Also if I tried the function =MAX(NOT(ISNA(A2))*A2,NOT(ISNA(B2))*B2), I don't get the value as 0 anymore like the first function you provided.

    Thanks
    Last edited by Jerseynjphillypa; 04-11-2012 at 09:20 AM.

  7. #7
    Forum Contributor
    Join Date
    10-16-2011
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    112

    Re: If and Or Statement

    Quote Originally Posted by Whizbang View Post
    Oops. I hadn't tested my formula.

    JosephP beat me to it:

    =MAX(IFERROR(A2,0),IFERROR(B2,0))


    IFERROR() is different than ISNA, though. Is there a specific reason you are testing for #N/A, or do you want to catch any error?
    The reason I have #N/A is because when i do a vlookup some of the values are not being found from the reference table

    Thanks for your help
    Last edited by Jerseynjphillypa; 04-11-2012 at 09:19 AM.

  8. #8
    Forum Contributor
    Join Date
    10-16-2011
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    112

    Re: If and Or Statement

    Quote Originally Posted by jraj1106 View Post
    Hello..

    Try this one and check:



    Regards...

    I notice your function is calling B3, the values should stay within the row only.

    Thanks

  9. #9
    Forum Contributor
    Join Date
    10-16-2011
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    112

    Re: If and Or Statement

    Quote Originally Posted by JosephP View Post
    how about
    =MAX(IFERROR(A2,0),IFERROR(B2,0))
    it just treats error values like 0
    Thanks for your help

  10. #10
    Valued Forum Contributor
    Join Date
    02-09-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    1,055

    Re: If and Or Statement

    Sorry..That was a mistake... its B2 and not B3

+ 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