+ Reply to Thread
Results 1 to 6 of 6

Evaluate non-blank, substitute and combine

  1. #1
    Registered User
    Join Date
    11-07-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    6

    Evaluate non-blank, substitute and combine

    I have a customer list, each supporting different products. The columns are fixed and the person entering data needs to "x" if that column header is used.
    What I need to do is combine all the non blank selections in the row and then populate a single cell to be used elsewhere.

    Attached is a spreadsheet of doing this with IF and SUBSTITUTE statements but it seems like there should be a better way.
    Customer 5 and 6 shows a comma in the combined cell I'd like to clean up and if you have a lot of columns this IF/SUBSTITUTE method I think gets to be a very ugly long formula.

    I had looked at INDEX/MATCH but just can't put it together with the substitution, so any clarifications are appreciated.

    Sample.png
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    12-25-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2016
    Posts
    506

    Re: Evaluate non-blank, substitute and combine

    Hi, this might not be the best solution but it at least get rid of the last comma and shall be less painful when expanding to more columns

    Formula: copy to clipboard
    Please Login or Register  to view this content.



    _______________________________________________________________________________________________________________________________
    1. Click on the * Add Reputation if you think someone helped you
    2. Mark your thread as SOLVED when question is resolved

    Alvin
    Last edited by alvin-chung; 12-27-2013 at 11:48 PM.

  3. #3
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Evaluate non-blank, substitute and combine

    Or this

    =SUBSTITUTE(TRIM(IFERROR(INDEX(B$5,MATCH("x",B6)),"")&" "&IFERROR(INDEX(C$5,MATCH("x",C6)),"")&" "&IFERROR(INDEX(D$5,MATCH("x",D6)),""))," ",", ")

    or even this (shorter version)


    =SUBSTITUTE(TRIM(IF(B$6:B$11="X",B$5,"")&" "&IF(C$6:C$11="X",C$5,"")&" "&IF(D$6:D$11="X",D$5,""))," ",", ")
    Last edited by AlKey; 12-28-2013 at 12:37 AM.
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  4. #4
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Evaluate non-blank, substitute and combine

    Here's a method that uses a user defined function.

    With your file open...

    Press the key combination of Alt+F11 to open the Visual Basic Editor

    Goto the menu Insert > Module

    Copy the VBA code at the link below and paste it into the window that opens on the right side of the screen:

    http://www.excelforum.com/showthread...=1#post3096647

    Press the key combination of ALT+Q to close the Visual Basic Editor and return to Excel.

    Data Range
    A
    B
    C
    D
    E
    5
    Customer
    Apple
    Orange
    Banana
    Fruits Used
    6
    Customer 1
    x
    x
    x
    Apple, Orange, Banana
    7
    Customer 2
    x
    Banana
    8
    Customer 3
    x
    x
    Orange, Banana
    9
    Customer 4
    x
    x
    Apple, Banana
    10
    Customer 5
    x
    Orange
    11
    Customer 6
    x
    Apple


    Enter this array formula** in E6 and copy down as needed:

    =concatall(IF(B6:D6="x",B$5:D$5,""),", ")

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

    You'll have to save the file as a macro enabled file in the *.xlsm file format.
    Last edited by Tony Valko; 12-27-2013 at 11:38 PM.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  5. #5
    Registered User
    Join Date
    11-07-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Evaluate non-blank, substitute and combine

    Thanks to everyone - I checked the VBA and also the simplified statement with the "TRIM" function and both accomplish the task.

  6. #6
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Evaluate non-blank, substitute and combine

    You're welcome. We appreciate the feedback!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Combine VLOOKUP and SUBSTITUTE Functions?
    By nobodyukno in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-03-2013, 11:00 AM
  2. SUMPRODUCT SUBSTITUTE with Blank Cells
    By onesNzeros in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-07-2013, 09:51 AM
  3. How to combine multiple substitute functions?
    By ron_b_michigan in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-03-2012, 11:15 AM
  4. Make Search formula evaluate to blank
    By XP in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-27-2006, 06:15 PM
  5. How to evaluate a blank field
    By Susan in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-03-2006, 11:25 AM

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