+ Reply to Thread
Results 1 to 10 of 10

Retrieve multiple field Names into a comma separated list for a matching value

  1. #1
    Registered User
    Join Date
    07-19-2013
    Location
    IND
    MS-Off Ver
    Excel 2010
    Posts
    4

    Retrieve multiple field Names into a comma separated list for a matching value

    Hi,
    I am a beginner at excel programming and trying to find a way to retrieve multiple field names into a comma separated list for a matching value based on multiple criteria.
    Here is how my data will look like. (Actual data will have entire month value. The lay out of field names in ).

    NAME DAY-1 DAY-2 DAY-3 DAY-4 DAY-5 DAY-6 DAY-7 DAY-8 DAY-9
    Resource 1 ;N; H; N; N; Y; Y; Y; L; Y
    Resource 2 ;N; H; N; N; Y; Y; Y; Y; Y


    If I give "Resource1" and "N" in 2 different cells , Then I should search in the table and retrieve field names with value N for Resource1. Here the expectation is to get DAY-1,DAY-3,DAY-4,

    Thank you for help in advance

  2. #2
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Re: Retrieve multiple field Names into a comma separated list for a matching value

    Someone else may know a better way, but the attached will give the desired results for a 3-day sample. Note formulas in row 6, and in cells B8 and B9.

    NameList.xlsx
    Acts 4:12
    Salvation is found in no one else, for there is no other name under heaven given to mankind by which we must be saved.

  3. #3
    Registered User
    Join Date
    07-19-2013
    Location
    IND
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Retrieve multiple field Names into a comma separated list for a matching value

    Thank you Natefarm for the help. I would need to use the 2-step approach here , but I have a method to start with.
    Also incase if there is a another field along with ResourceName and N, what would be the method?
    I need to try on those lines, if not I will concatenate, the 2 string fields into 1 and I will use it

  4. #4
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Re: Retrieve multiple field Names into a comma separated list for a matching value

    I would need to see an example of what you are talking about.

  5. #5
    Registered User
    Join Date
    07-19-2013
    Location
    IND
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Retrieve multiple field Names into a comma separated list for a matching value

    Hi, I was working on the below form of data
    Group Name Day-1 Day-2 Day-3 Day-4
    G1 R1 H H N N
    G2 R2 N H H H
    G1 R3 H H N N
    G2 R4 N H H H
    G1 R5 N N N N
    G2 R6 N N H H
    G1 R7 N N N N
    G2 R8 N H N H

    For the time being I combined the data in first 2 columns into a third column and working on the formula you shared.
    KEY Day-1 Day-2 Day-3 Day-4
    G1R1 H H N N
    G2R2 N H H H
    G1R3 H H N N
    G2R4 N H H H
    G1R5 N N N N
    G2R6 N N H H
    G1R7 N N N N
    G2R8 N H N H

  6. #6
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Re: Retrieve multiple field Names into a comma separated list for a matching value

    You're on the right track. Here's an adjusted version.

    NameList.xlsx

    Hiding column C and rows 11 and 12 would provide cleaner results.

  7. #7
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Retrieve multiple field Names into a comma separated list for a matching value

    Using natefarm's original workbook, here is an expanded version up to 31 days and R10.

    I modified the formula to count the columns in the VLOOKUP and added IFERROR to take care of blank cells which would cause an error.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    The concatenation is accomplished with this formula (real ugly)
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    The other formulae were left alone.
    Attached Files Attached Files
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

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

    Re: Retrieve multiple field Names into a comma separated list for a matching value

    Here's another way that uses a VBA function.

    Copy the code at this link and paste it into a general module:

    https://www.excelforum.com/showthread.php?p=3096647

    Data Range
    A
    B
    C
    D
    E
    F
    G
    H
    I
    J
    1
    NAME
    DAY-1
    DAY-2
    DAY-3
    DAY-4
    DAY-5
    ------
    Name
    Status
    ------
    2
    Resource 1
    N
    H
    N
    N
    Y
    Resource 1
    N
    DAY-1, DAY-3, DAY-4
    3
    Resource 2
    N
    H
    N
    N
    Y


    This array formula** entered in J2:

    =concatall(IF(INDEX(B2:F3,MATCH(H2,A2:A3,0),0)=I2,B1:F1,""),", ")

    ** 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.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  9. #9
    Registered User
    Join Date
    07-19-2013
    Location
    IND
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Retrieve multiple field Names into a comma separated list for a matching value

    Thank you all for the different options.

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

    Re: Retrieve multiple field Names into a comma separated list for a matching value

    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. Multiple Select Listbox Comma Separated List with Filtering
    By StephenieG in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-28-2020, 01:18 PM
  2. [SOLVED] Vlookup table array matching with multiple value in single cell separated by comma.
    By kannoy in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 03-04-2015, 04:03 AM
  3. [SOLVED] Extract list - Comma separated
    By TheCman81 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 07-28-2014, 09:29 AM
  4. Comma separated list of values help needed
    By handcoded in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-07-2014, 11:41 AM
  5. Replies: 1
    Last Post: 07-24-2012, 04:13 AM
  6. Return Y/N after matching from multiple lookup values separated by comma
    By indoglans in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-16-2011, 03:13 PM
  7. Going from column to comma separated list...
    By jmboggiano in forum Excel General
    Replies: 1
    Last Post: 03-10-2005, 01:06 PM

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