+ Reply to Thread
Results 1 to 4 of 4

IF function

Hybrid View

  1. #1
    Registered User
    Join Date
    02-09-2011
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    2

    IF function

    Hi,

    I have searched for about an hour, but I do not know enough to search for the proper tutorial. Anyways, I need a function to add lets say cells B2&C2, but if B2 = "DNI" then the output be C2. If C2="DNI" then the output B2. If both say DNI then the output "DNI".

    Can anyone help?

    This is what I have came up with so far. (This is after about 1/2 hour of tutorials haha.)

    =IF(AND(B9="DNI",C9="DNI"),"DNI",B9+C9)

    *The problem is this only helps me if both cells read DNI. If only one reads DNI and the other is a number I would receive incorrect information.
    Last edited by joenicky; 02-09-2011 at 01:44 PM.

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: I need help with IF functions.

    Either of these approaches will work:
    =IF(AND(B1="DNI",C1="DNI"),"DNI",SUM(B1:C1))
    or
    =IF(COUNTIF(B1:C1,"DNI")=2,"DNI",SUM(B1:C1))


    Does that help?
    Last edited by Ron Coderre; 02-09-2011 at 01:44 PM. Reason: Changed semi-colons to commas...User is listed as from the USA
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Registered User
    Join Date
    02-09-2011
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: I need help with IF functions.

    Quote Originally Posted by Ron Coderre View Post
    Either of these approaches will work:
    =IF(AND(B1="DNI",C1="DNI"),"DNI",SUM(B1:C1))
    or
    =IF(COUNTIF(B1:C1,"DNI")=2,"DNI",SUM(B1:C1))


    Does that help?
    The second one worked great. What is that countif? Thank you for the help!

  4. #4
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: I need help with IF functions.

    OOps! I co-mingled two responses...this is edited to correct that:
    COUNTIF returns the count of cells that contain a pattern...in this case: equals "DNI".
    So, if both cells contain DNI, the count = 2
    Last edited by Ron Coderre; 02-09-2011 at 03:14 PM.

+ 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