+ Reply to Thread
Results 1 to 4 of 4

Populate Keyword List based on Pattern

  1. #1
    Registered User
    Join Date
    01-03-2010
    Location
    Cyprus
    MS-Off Ver
    Excel 2007
    Posts
    14

    Populate Keyword List based on Pattern

    Hello,

    I am not sure if this can be solved through formulas or if it needs to be some Macro. I have tried myself with my little knowledge of formulas and didn't succeed.
    I have 2 sheets :
    1/ Drinks (with drinks Names)
    2/ Patterns

    I want to output on a 3rd sheet :
    The combination of Drinks and Patterns where the XX in Pattern should be replaced By the First Drink Name until the end of the pattern and then, move on to build a second list below with the second Drink name, etc.

    Thanks in advance
    Attached Files Attached Files
    Last edited by ypnOz; 11-14-2013 at 10:35 AM.

  2. #2
    Forum Expert ben_hensel's Avatar
    Join Date
    01-26-2012
    Location
    Northeast USA
    MS-Off Ver
    Office 365
    Posts
    2,043

    Re: Populate Keyword List based on Pattern

    I copy/pasted the data all onto one sheet to make it simplier for an example.

    I also used some index numbers, split the prefix/suffix of the PATTERN into two columns, and used helper columns, all to make the calculation simplier to follow; it's not impossible to nest all of it, it's just that it would be much harder to follow.

    (For example, if you left the PATTERN string as it was, you would have to run an IF to determine where the XXX was on either side of the DRINK to determine whether it was a prefix or a suffix, and then replace "XXX" with "" before concatenation. Not impossible, just too much complication for an example).

    Anyway, solve this by using INDIRECT to find the row, based on the division and modulus of the index compared to the counts of the word.
    Attached Files Attached Files

  3. #3
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,724

    Re: Populate Keyword List based on Pattern

    You can use this formula on row 1 of the results sheet:

    =IF(ROWS($1:1)>(COUNTA(drinks!A:A)-1)*(COUNTA(pattern!A:A)-1),"",SUBSTITUTE(INDEX(pattern!A:A,MOD(ROWS($1:1)-1,COUNTA(pattern!A:A)-1)+2),"XX",INDEX(drinks!A:A,INT((ROWS($1:1)-1)/(COUNTA(pattern!A:A)-1))+2)))

    and then just copy down as far as you need to (until you get blanks).

    I've added some extra drinks and another pattern in the attached file to show that the formula automatically adjusts.

    Hope this helps.

    Pete
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    01-03-2010
    Location
    Cyprus
    MS-Off Ver
    Excel 2007
    Posts
    14

    Thumbs up Re: Populate Keyword List based on Pattern

    Thanks a lot to both of you!!
    It's exactly what I needed

+ 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. Macro To Find & Copy Rows Based On A Keyword List
    By Lilfish in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-02-2013, 10:02 AM
  2. [SOLVED] Macro to display rows from another tab, based on 2 criteria (List and keyword)
    By KenzoMinamoto in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-25-2013, 09:17 PM
  3. Filter List by Keyword & copy the result in column by keyword as header
    By kitunga in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-21-2013, 07:16 AM
  4. [SOLVED] Populate Listbox from 2 columns based on search keyword from text box
    By sivakumar123 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-05-2012, 12:22 AM
  5. Populate a cell based on a keyword it found in another
    By ghobbit in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 05-15-2006, 11:47 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