+ Reply to Thread
Results 1 to 9 of 9

See if string contains any of the keywords on a table and return nickname of that keyword

  1. #1
    Registered User
    Join Date
    07-29-2014
    Location
    Montreal, Canada
    MS-Off Ver
    2007
    Posts
    10

    See if string contains any of the keywords on a table and return nickname of that keyword

    PROJECT IDENTIFICATION .xlsm


    Hi everyone,

    So I have been searching everywhere and cannot find a VBA code to salvage, that,

    would look in a string (Column H of sheet 1 ) see if it finds a keyword (from (ProjectID) Column B of sheet 2) within that string and return on Column R of sheet1 the matching ProjectID's project name written on Column C of Sheet 2 for each row of sheet 1



    The project ID Table is on sheet 2

    Column B has the Project ID and Column C has the Project name
    Column A has a sorting alphanumerical code to allow the Most Unique Project ID to be at the bottom to help avoid false positives.



    examples of string in (column H of sheet 1) =
    USER,JOB TYPE,PROJECT1-010,BATCH 1026 >>>>>>>>> "should return PROJECT 1"
    USER,JOB TYPE,PROJECT2-020,BB.BATCH 1026 >>>>>>>>> "Should return BB"
    USER,JOB TYPE,PROJECT3-030,CC,BATCH 1026 >>>>>>>>> "Should return CC"

    example of project table (columns B and C of Sheet 2) =

    (B)PROJECT ID--------(C)PROJECT NAME
    ,PROJECT1-010--------PROJECT 1
    ,PROJECT2-020,BB--------BB
    ,PROJECT3-030,CC--------CC



    SO if Sheet1's column (H) string CONTAINS (A PROJECT ID ) THEN (R) = PROJECT NAME(Column B

    I would later try to add two more conditions:


    IF column (N) CONTAINS the word "EXTRA" THEN (R) = EXTRA

    IF column (H) CONTAINS NON OF THE PROJECTS AND IS NOT EXTRA THEN(R)= REGULAR



    This macro needs to run for as many rows that are in sheet 1 that the value of Column A's cell 's formula is not blank. and start from the top of sheet1 when run and all the way down until Column A's Formula's Result is BLANK.

    The I Idea is to be able to add any new Project ID and have it recognized somewhere in Column H's String and populate the proper project name.


    Any help would be appropriated

    I can send u the sheets if u send me your email.

    I hope I was as clear as possible
    ask me if I forgot to specify something
    Last edited by speedyacct; 07-30-2014 at 01:23 PM.

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: See if string contains any of the keywords on a table and return nickname of that key

    Submit a copy of your workbook so we have something to test the code against. Feel free to remove any sensitive information but please leave the information in the columns that you referenced.

  3. #3
    Registered User
    Join Date
    07-29-2014
    Location
    Montreal, Canada
    MS-Off Ver
    2007
    Posts
    10

    Re: See if string contains any of the keywords on a table and return nickname of that key

    https://onedrive.live.com/redir?resi...D409CDD1%21893 is the link to download the Sheet

    once open please click on File/ Save as to save locally

    private message me to have my email to send it back


    I have also attached a copy to the original post .


    Thank you
    Last edited by speedyacct; 07-30-2014 at 01:42 PM.

  4. #4
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: See if string contains any of the keywords on a table and return nickname of that key

    Try this:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    07-29-2014
    Location
    Montreal, Canada
    MS-Off Ver
    2007
    Posts
    10

    Re: See if string contains any of the keywords on a table and return nickname of that key

    Thank you Sir, I really appreciate the time you put into this

    I wish I had your skills on this ,

    2 Questions:

    can the code be completely independent of commas ?

    arrSplit = Split(rCell.Value, ",")
    str = arrSplit(2) seems to be looking for Comma in the String... x2 sadly the commas are not necessarily in that order to have the project id written after the second comma,

    Is there a way to have this work without taking in consideration the position of commas ?

    there always will be a comma before the Project ID but there could be more or less Commas before it
    i could add the comma before the project id in the table if that helps but the code has to be able to find the project id regardless of it's position in the string.



    also Where would you Add a stop to the calculations so that it runs and all the way down on sheet 1 until Column A's Formula's Result is BLANK.
    Last edited by speedyacct; 07-30-2014 at 03:02 PM.

  6. #6
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: See if string contains any of the keywords on a table and return nickname of that key

    Is the string "PROJECT" consistent in column H? In other words, PROJECT1, PROJECT2, etc? If so we can test each element of the array against that string and use that to locate the strings location within the array. This will make the code work regardless of how many commas are before or after it.

    Please Login or Register  to view this content.
    also Where would you Add a stop to the calculations so that it runs and all the way down on sheet 1 until Column A's Formula's Result is BLANK.
    I don't understand what you mean by this

  7. #7
    Registered User
    Join Date
    07-29-2014
    Location
    Montreal, Canada
    MS-Off Ver
    2007
    Posts
    10

    Re: See if string contains any of the keywords on a table and return nickname of that key

    for :

    Is the string "PROJECT" consistent in column H?

    answer: Sadly on this i know it would have helped but It will not always be PROJECT...., I was hoping the code can pickup any Project ID on the table and look for each Project ID in B of Projects for all Rows of H on LIVE ALL

    for
    also Where would you Add a stop to the calculations so that it runs and all the way down on sheet 1 until Column A's Formula's Result is BLANK.

    answer :
    The LIVE ALL sheet get's its info from "DATA" sheet
    and the code would have to only try to determine Projects in LIVE ALL for it's rows that have data ....
    new reports will be pasted over the data sheet and the number of rows will grow... and will keep displaying in LIVE ALL

    the live all sheet if fully formula's except Column R that is handled by VBA

    so all cells in LIVE ALL refer to "DATA"Sheet

    like this = =DATA!A:A and so on ..

    so the code has to recognize the value of A's cell is blank even if the cell itself has =DATA!A:A ( but has no data in it yet ) and is showing blank.

    LIVE ALL Sheet will be formulas down to 20K until DATA SHEET grows to more so I will then drag it down more

    That's why if the code can recognize that it needs to stop running once it hits the first blank result of A on LIVE ALL

  8. #8
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: See if string contains any of the keywords on a table and return nickname of that key

    The amended code will not populate column R for cells that do have a value in columns A or H regardless if a formula exists. If you are implying that you will have multiple sections within the "LIVE ALL" sheet which will be separated by a blank row and you only want the code to apply to one section, it's possible but you will probably want to rethink your layout as it is prone to errors. Either way; I have altered the code to look at the values in the projects worksheet and base it off that rather than the Live all sheet.

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    07-29-2014
    Location
    Montreal, Canada
    MS-Off Ver
    2007
    Posts
    10

    Re: See if string contains any of the keywords on a table and return nickname of that key

    THANK YOU I just tested it
    and

    THIS IS IT !!!! thank you !

    AND You aright i see what u mean about that, no need to stop the code I'm more of a formula guy so I always have to take in account blanks ! lol
    Thank you Very much !
    This Totally did the trick

+ 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] HDI - Return multiple keywords in a text column based on a set of available keywords
    By zneiley in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-25-2013, 01:32 PM
  2. [SOLVED] Need to chck if a keyword is present in a text string and return keyword if yes
    By Jekaterina in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 12-16-2012, 05:55 PM
  3. Finding instances of a keyword from another set of keywords
    By electricice in forum Excel General
    Replies: 3
    Last Post: 06-10-2011, 04:00 AM
  4. Replies: 1
    Last Post: 01-15-2010, 05:29 AM
  5. Keyword search, several keywords
    By Doman in forum Excel General
    Replies: 1
    Last Post: 07-24-2006, 06:05 AM

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