+ Reply to Thread
Results 1 to 9 of 9

Excel 2007 : Excel IF formula with multiple returns

  1. #1
    Registered User
    Join Date
    03-28-2011
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    4

    Excel IF formula with multiple returns

    Hi...need some help! I have a number of columns with Yes or No data...I need to create a formula that will return text for EACH of the Yes values into ONE field.
    Example...
    Let's say the columns are labled "Toys", "Music", "Games", "Food", "Books", "Plants"...
    One particular row under these headings might say "Yes", "Yes", "No", "No", "Yes".
    How would you write a formula that will return the following text: "Toys - Music - Plants" ?
    Last edited by sixstringirl; 03-28-2011 at 05:35 PM.

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

    Re: Excel IF formula with multiple returns

    These are concatenation formulas, usually.

    =A1 & " - " & B1 & " - " & C1

    But this often isn't all that is necessary to get your end results to look correct.

    Click GO ADVANCED and use the paperclip icon to post up a copy of your workbook, mockup the desired results you want to see right on the sheet itself.
    _________________
    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!)

  3. #3
    Registered User
    Join Date
    03-28-2011
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Excel IF formula with multiple returns

    Ok...here is an example of what I need in column AB

    Thanks for your help!!
    Attached Files Attached Files

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

    Re: Excel IF formula with multiple returns

    This ability is not inherent to Excel. But there are people who have created special User Defined Functions to do this easily for you. My favorite is called CONCATIF() and it functions a lot like a SUMIF() formula.

    First, here's the code for the new function.

    Please Login or Register  to view this content.
    It's used just like a SUMIF() formula, but it has two extra parameters.

    =ConCatIf(D2:AA2,"yes",$D$1:$AA$1," - ",TRUE)

    First parameter: Range to evaluate
    Second param: comparison string.
    Third param: Range to return values from
    Fourth param: The delimiting string for the concatenation
    Fifth param: (optional) TRUE means eliminate duplicated values, FALSE (or omitted) means string all values

    This should give you enough info to apply this UDF to your sheet and use it place of that formula of your own.

    How to install the User Defined Function:

    1. Open up your workbook
    2. Get into VB Editor (Press Alt+F11)
    3. Insert a new module (Insert > Module)
    4. Copy and Paste in your code (given above)
    5. Get out of VBA (Press Alt+Q)
    6. Save as a macro-enabled workbook

    The function is installed and ready to use.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    03-28-2011
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Excel IF formula with multiple returns

    Jerry -- this is wonderful!! I applied it to my example and it worked perfectly, but in my actual worksheet the columns in question are AD - BA (instead of D - AA), so I did everything the same but adjusted the formula to this: =ConCatIf(AD2:BA2,"yes",$AD$1:$BA$1," - ",TRUE) But it doesn't seem to be working...all I get is #NAME? Where am I going wrong now?

    Wait...don't answer...I think I've found my error!!

    YESSSSSSSSSSSSSSSSSSS!!! It's working!!

    Thanks, Jerry.... excellent assistance!! Many thanks! <3
    Last edited by sixstringirl; 03-28-2011 at 05:24 PM.

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

    Re: Excel IF formula with multiple returns

    Glad to help, though the credit for this one really goes to Mike Rickson.

    If that takes care of your need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  7. #7
    Registered User
    Join Date
    03-28-2011
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Excel IF formula with multiple returns

    Ok...my thanks to Mike Rickson too!!!!

    take care.

  8. #8
    Valued Forum Contributor scottylad2's Avatar
    Join Date
    09-03-2010
    Location
    edinburgh
    MS-Off Ver
    Office 2007 Prof & Office 2010 Student Edition
    Posts
    629

    Re: Excel IF formula with multiple returns

    Jerry, whats the process for saving this as a function/Addin that can be used in any workbook?
    Windows 7 using Office 2007 & 2010

    Remember your [ code ] [ /code ] tags, makes reading soooo much easier

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

    Re: Excel IF formula with multiple returns

    I don't do addins, its a philosophical difference only. I can embed the function into the workbooks needed and they travel with the workbook out to anyone I send them to and they keep functioning properly. If I went the ADDIN route I'd have to be instructing others on how to add in the addin on all their computers. Nah.

    Meanwhile, turning a UDF into an addin is simple. Google that question and you'll get 100s of answers.

    Also, Scottlady2, you know the rules about hijacking people's threads with your own questions, and this is about as unrelated as you can get while still being slightly related.
    Last edited by JBeaucaire; 03-29-2011 at 02:04 AM.

+ 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