+ Reply to Thread
Results 1 to 9 of 9

Combining two separate functions into one function

  1. #1
    Registered User
    Join Date
    02-16-2010
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    10

    Combining two separate functions into one function

    Hello, this is my first time posting. I had posted this question in the general forum, and I would erase from there it if I could since I know I'm not supposed to double post.

    The question seemed more relevant in this "new users" forum because I'm totally new to Excel and trying to figure things out. So perhaps a moderator can erase the original post.

    I'm trying to create a function for cell B2 that would have the following components:

    If cell B3 is the letter "A" and cell B4 < 0, then output the word "YES"; otherwise output the word "NO." I have managed to make this component work by itself:

    =IF(AND(B3="A",(B4<0)),"YES","NO")


    Also, if B3 is the letter "Z" and B4 < 0, then output the word "NO"; otherwise output the word "YES." That string works by itself:

    =IF(AND(B3="Z",(B4<0)),"NO","YES")

    What I am having a ridiculously hard time figuring out is how to include both strings in the same formula. I'm sure it's not too hard, but I just can't seem to do it. I think it must involve the "OR" command somehow...? Thanks for any help!
    Last edited by Capa; 02-19-2010 at 02:42 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    02-08-2010
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2007
    Posts
    122

    Re: Combining two separate functions into one function

    Try this

    =IF(AND(OR(B3="A",B3="Z"),B4<0),"NO","YES")

    Regards

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Combining two separate functions into one function

    I would think it would be:

    =IF(OR(AND(B3="Z",B4<0), AND(B3="A",B4>=0)), "NO", "YES")
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Registered User
    Join Date
    02-16-2010
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Combining two separate functions into one function

    Quote Originally Posted by sailepaty View Post
    Try this

    =IF(AND(OR(B3="A",B3="Z"),B4<0),"NO","YES")

    Regards
    Thank you, but the problem is that I want it to say "NO" if B4<0 *only* when B3="A". In the second condition of the OR, B3=Z, it's the reverse. In that case I would want it to say "YES" if B4<0 and "NO" otherwise.

    The way it's written above, it will output the same word regardless of whether B3="A" or "Z", but I want it to output the opposite word for each case.

    Thanks again!

  5. #5
    Registered User
    Join Date
    02-16-2010
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Combining two separate functions into one function

    Quote Originally Posted by JBeaucaire View Post
    I would think it would be:

    =IF(OR(AND(B3="Z",B4<0), AND(B3="A",B4>=0)), "NO", "YES")

    Worked perfectly! Thanks for the help, awesome site

  6. #6
    Valued Forum Contributor
    Join Date
    02-08-2010
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2007
    Posts
    122

    Re: Combining two separate functions into one function

    Mine was a wrong answear.
    Last edited by sailepaty; 02-16-2010 at 03:14 PM.

  7. #7
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Combining two separate functions into one function

    Hi,

    Try
    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Combining two separate functions into one function

    If that takes care of your need, be sure to EDIT your original post, click Go Advanced and mark the PREFIX box [SOLVED].

    ============
    (Also, use the blue "scales" icon in our posts to leave Reputation Feedback, it is appreciated. It is found across from the "time" in each of our posts.)

  9. #9
    Registered User
    Join Date
    02-16-2010
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Combining two separate functions into one function

    Quote Originally Posted by JBeaucaire View Post
    If that takes care of your need, be sure to EDIT your original post, click Go Advanced and mark the PREFIX box [SOLVED].

    ============
    (Also, use the blue "scales" icon in our posts to leave Reputation Feedback, it is appreciated. It is found across from the "time" in each of our posts.)
    Ok, I did both. just saw your post now.

+ 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