+ Reply to Thread
Results 1 to 4 of 4

Help regarding if-else

Hybrid View

  1. #1
    Registered User
    Join Date
    06-18-2017
    Location
    Kolkata, India
    MS-Off Ver
    2013
    Posts
    3

    Help regarding if-else

    Let me describe what I want to implement.
    There are two columns, say 'D' & 'E'; each can take either of the two values 0 or 1. Now, in a third column, say 'G', I want to see results based on the product of values of the two columns D & E. If the product is a 1, I want to see the output as 'YES' and if the product is a 0, I want to see a 'NO'. I have figured out how to do it: =IF(D4*E4=1, "YES", IF(D4*E4=0, "NO", "")). My thought behind using the nested if is that the cell would remain blank if there are no vales input in the cells of D & E. But sadly, it's not happening. When I apply the given if-condition to a range of cells in the column G, all the cells take a default output of "NO".
    How can I get what I want? If the output value is 0, then NO; if it's 1, then a yes, and if no values are input yet, I want them to remain blank.

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,883

    Re: Help regarding if-else

    Try

    =IF(OR(D4="",E4=""),"",IF(D4*E4,"Yes","NO"))

  3. #3
    Registered User
    Join Date
    06-18-2017
    Location
    Kolkata, India
    MS-Off Ver
    2013
    Posts
    3

    Re: Help regarding if-else

    It's working.
    Thanks a ton.
    But can you tell me how did that piece of code work?

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,883

    Re: Help regarding if-else

    =IF(OR(D4="",E4=""),"",IF(D4*E4,"Yes","No"))

    The OR tests if either D4 or E4 is blank and result is blank

    the IF test returns TRUE condition if D4*E4 is 1 (any value other than 0 will return TRUE) , so results is "Yes", otherwise "No"

    The formula below is the equivalent .....

    =IF(OR(D4="",E4=""),"",IF(D4*E4=1,"Yes","No"))

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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