+ Reply to Thread
Results 1 to 4 of 4

Match row that contains text text string; list associated values from pivot table

  1. #1
    Registered User
    Join Date
    12-17-2008
    Location
    Seattle, WA
    Posts
    39

    Match row that contains text text string; list associated values from pivot table

    Hi everyone,

    Please refer to the attached workbook for reference.

    I am looking for a function in Sheet1, Column E that will search for the value of Sheet1, Column A within Sheet2, Column A. When a match is found, the function should look across Sheet2, Columns B - V for values of 1. When such values are found, the function should return the associated value from Sheet2, Row 2. There may be multiple values of 1, and as such, the function should separate values with a comma.

    I appreciate your help!

    Thanks and best regards,
    ACurtis802
    Attached Files Attached Files
    Last edited by ACurtis802; 03-29-2009 at 10:27 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: Match row that contains text text string; list associated values from pivot table

    This was a little convoluted. First, we need to use a trick to identify which row to use, then use and INDIRECT formula to construct a range reference from it.

    =MATCH(Sheet1!C2&"/"&Sheet1!A2,Sheet2!$A$1:$A$100,0)

    This matches the Factory Name and Partner Code against the picot table on Sheet2 and returns the row number.

    Now, we wrap that into an ADDRESS() function to convert the answer to a beginning cell reference:

    =ADDRESS(MATCH(Sheet1!C2&"/"&Sheet1!A2,Sheet2!$A$1:$A$100,0),2)
    ...which resolved to $B$3 in cell E2.

    Now we do that AGAIN with some concatenation to create the whole range:

    =ADDRESS(MATCH(Sheet1!C2&"/"&Sheet1!A2,Sheet2!$A$1:$A$100,0),2)&":"&ADDRESS(MATCH(Sheet1!C2&"/"&Sheet1!A2,Sheet2!$A$1:$A$100,0),22))
    ...which resolved to $B$3:$V$3 in cell E2...so now we know the range to match the 1's in.

    To get your final result, we need a StringConcatenation tool that allows a variable test to be applied. I installed Chip Pearson's StringConcat() function into your sheet to accomplish this.

    The final resulting ARRAY formula is:

    =stringconcat(", ",IF(INDIRECT("Sheet2!"&ADDRESS(MATCH(Sheet1!C2&"/"&Sheet1!A2,Sheet2!$A$1:$A$100,0),2)&":"&ADDRESS(MATCH(Sheet1!C2&"/"&Sheet1!A2,Sheet2!$A$1:$A$100,0),22))=1,Sheet2!$B$2:$V$2,""))

    Notice we wrapped our long formula above into an INDIRECT() so that it becomes an active range instead of a text string. Then we compare that range looking for 1s. If a 1 is found, it String-Concatenations the Brands separating by a comma.

    Those array have to be activated with a CTRL-SHIFT-ENTER...and braces { } will appear around your formula and results will appear. If you just press ENTER the cell will go blank because the array is broken.
    Attached Files Attached Files
    Last edited by JBeaucaire; 03-29-2009 at 03:08 AM.
    _________________
    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
    12-17-2008
    Location
    Seattle, WA
    Posts
    39

    Re: Match row that contains text text string; list associated values from pivot table

    Brilliant, JBeaucaire! Thank you.

  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: Match row that contains text text string; list associated values from pivot table

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

+ 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