+ Reply to Thread
Results 1 to 10 of 10

Thread: Formula to look up and populate?

  1. #1
    Registered User
    Join Date
    10-29-2010
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2007
    Posts
    5

    Formula to look up and populate?

    I'm essential building a table from the data in another table. Example:

    Reference table
    ColumnA | ColumB
    coat | black, brown, red
    hat | black, brown, green
    pants | black, brown
    shirt | red, blue, green
    tie | brown, blue, green

    New Table- Need cells in ColumnB to equal all things that match ColumnA
    ColumnA | ColumB (Examples provided)
    black | Example: coat, hat, pants
    brown | Example: coat, hat, pants, tie
    red | Example: coat, shirt
    green | Example hat, shirt, tie
    blue | Example: shirt, tie

    Any ideas on how I can do this?

  2. #2
    Forum Guru, retired Admin royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    25,639

    Re: Formula to look up and populate?

    To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    If needed supply a before and after sheet in the workbook so the person helping you can see what you are trying to achieve.

    Doing this will ensure you get the result you need!
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel Tips & Solutions, free examples and tutorials why not check out my downloads

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)

  3. #3
    Registered User
    Join Date
    10-29-2010
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Formula to look up and populate?

    PYR....attached a sample...
    Attached Files Attached Files

  4. #4
    Forum Guru, retired Admin royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    25,639

    Re: Formula to look up and populate?

    You can't use Lookups with empty columns in the data
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel Tips & Solutions, free examples and tutorials why not check out my downloads

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)

  5. #5
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,423

    Re: Formula to look up and populate?

    Are you looking for a "Native" or VBA Function (UDF) to do this ? (or sub routine for that matter)

    Non-VBA would necessitate "helpers" (IMO) - in terms of scalable solution.

  6. #6
    Registered User
    Join Date
    10-29-2010
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Formula to look up and populate?

    Well, I know there are things like vlookups and hlookups. I have tried vlookups but I've only been able to get it to return the last item matched...not all matching items.

    The tables are not that large, maybe 100 or so line items. I think a native solution would be ideal, but I am open to anything that is easy and works.

  7. #7
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,423

    Re: Formula to look up and populate?

    OK - using your sample file and specifically Before Sheet

    F1
    =INDEX($A:$A,2+(COLUMNS($F1:F1)-1))
    copied across to say P1
    
    F2:
    =IF(OR(F$1=0,$D2&$E2=""),"",REPT(F1,(ROWS(F$2:F2)<>1))&REPT(","&$D2,ISNUMBER(SEARCH(", "&F$1&",",", "&$E2&","))))
    copied across matrix say F2:P10
    with the above in place we can generate the results

    B2:
    =IF($B2="","",REPLACE(INDEX($F:$P,MATCH(REPT("Z",255),$D:$D),ROWS(B$2:B2)),1,1,""))
    copied down to say B10
    If you then add additional colours per the Ref Table then the data should update automatically - eg:

    A7: pink
    D7: shoes
    E7: black, pink
    you should find the data (B2, B7) updates accordingly

  8. #8
    Registered User
    Join Date
    10-29-2010
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Formula to look up and populate?

    Thank you very much for the quick replies!!

    I tried plugging in your suggestions...not sure if I did something wrong or not, but after populating F1:P1 and F2:P10 per your instructions I get an error:
    "Cell references in the formula refer to the formula's result, creating a circular reference."

    My attempt is attached in tmn_sample_2.xlsx. It looks like row 6 is the data I'm looking for (minus the leading ",") This is far closer then I've been able to get on my own
    Attached Files Attached Files

  9. #9
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,423

    Re: Formula to look up and populate?

    Sorry typo on my part - B2 formula should begin with:

    =IF($A2=""
    rather than

    =IF($B2=""

  10. #10
    Registered User
    Join Date
    10-29-2010
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Formula to look up and populate?

    SWEET!!!! Thank you very much!! Worked like a charm!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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.2.0