Consulting

Results 1 to 18 of 18

Thread: Search multiple keywords to filter column

  1. #1
    VBAX Regular
    Joined
    Jun 2019
    Posts
    10
    Location

    Search multiple keywords to filter column

    Hi

    I have a spreadsheet that will be updated weekly with info drawn from a tender/contract website.

    This will be going to multiple people and they would like to filter according to keywords in the tender 'description' box.

    I have managed to set up a VBA/macro search box where they can input a keyword and the list will be filtered accordingly, for that one word.

    I'd like to be able to go a step further and allow them to click on a macro button that would filter the list for ANY of a list of keywords in the description column.

    e.g if they were interested in IT related contracts they would like to see only contracts containing any of the words "Network" "Data" "IT" "Computer" "Cloud" etc. etc.

    Is there an easy way to do this?

    I'm guessing it would use Advanced Filter rather than autofilter (which I used for the basic search) but not sure of the possibilities.

    Many thanks in advance

  2. #2
    VBAX Mentor
    Joined
    Apr 2009
    Location
    Kingsbury
    Posts
    423
    Location
    Hi Bat71
    You need to post a copy of the workbook as a test sample and possibly a copy of what you want the results to look like
    Rob

  3. #3
    VBAX Regular
    Joined
    Jun 2019
    Posts
    10
    Location
    Quote Originally Posted by Rob342 View Post
    Hi Bat71
    You need to post a copy of the workbook as a test sample and possibly a copy of what you want the results to look like
    Rob
    Hi Rob

    I can't really post a copy as the information which I have pasted into the workbook is from a paid website.

    I'm really just asking is there a way to filter a column based on a list of keywords.

    So each contract has a description field, and I want to be able to look for any word (from a list of words) that appears in that description and then filter that column.

    e.g. my keywords are "IT" "Cloud" "Artificial Intelligence" "Networking" and I would like the filter to only return those rows where one or more of these words appear, so that the person who is only interested in IT contracts will only see those.

    I might be trying to do something that isn't really possible!

  4. #4
    VBAX Mentor
    Joined
    Apr 2009
    Location
    Kingsbury
    Posts
    423
    Location
    Hi
    Which column do these key words appear and what sheet
    or a copy of the code you are using for your search routine

    Rob
    Last edited by Rob342; 06-05-2019 at 02:39 PM.

  5. #5
    VBAX Mentor 大灰狼1976's Avatar
    Joined
    Dec 2018
    Location
    SuZhou China
    Posts
    479
    Location
    Hi Bat71!
    Autofilter can also implement the functions you want,
    But the lower version of EXCEL may not be applicable, not sure.
    please refer to the attachment.
    Attached Files Attached Files

  6. #6
    VBAX Mentor 大灰狼1976's Avatar
    Joined
    Dec 2018
    Location
    SuZhou China
    Posts
    479
    Location
    You can also used wildcard character like "*B*,*E" and so on.

  7. #7
    VBAX Regular
    Joined
    Jun 2019
    Posts
    10
    Location
    Hi 大灰狼1976, that is what I need!

    I will have a go at putting this in sheet.

    Many thanks

    Matt

  8. #8
    VBAX Mentor 大灰狼1976's Avatar
    Joined
    Dec 2018
    Location
    SuZhou China
    Posts
    479
    Location
    You're welcome

  9. #9
    VBAX Regular
    Joined
    Jun 2019
    Posts
    10
    Location
    Hi

    I have tried this and works in your example, but the descriptions I have are long lists, e.g. like this:

    Urban Planning, Urban Regeneration, Masterplan, Town Planning, Community Engagement, Area Development, Spatial Development, Economic Regeneration, Community Planning, Spatial Planning, Planning Consultants, Regeneration Partner

    So for example, if i wanted to filter those descriptions which mention the keyword 'Planning' or 'Development', is this possible?

  10. #10
    VBAX Mentor
    Joined
    Dec 2008
    Posts
    404
    Location
    Bat71, read post #6 carefully.

    Artik

  11. #11
    VBAX Regular
    Joined
    Jun 2019
    Posts
    10
    Location
    Ah, ok, will try it out!

  12. #12
    VBAX Regular
    Joined
    Jun 2019
    Posts
    10
    Location
    Quote Originally Posted by Artik View Post
    Bat71, read post #6 carefully.

    Artik
    Works!

    Thanks all

  13. #13
    VBAX Regular
    Joined
    Jun 2019
    Posts
    10
    Location
    Just one more quick question, if I want to keep the keywords on a separate sheet, just to keep things tidy, what do I need to add to this line?

    arr = Split([r1], ",")

  14. #14
    VBAX Regular
    Joined
    Jun 2019
    Posts
    10
    Location
    Also, I can only seem to add two (wildcard) keywords for some reason, any more than that and the search stops working

  15. #15
    VBAX Regular
    Joined
    Jun 2019
    Posts
    10
    Location
    I've just read that 2 wildcards might be my limit!

  16. #16
    VBAX Mentor
    Joined
    Dec 2008
    Posts
    404
    Location
    Quote Originally Posted by Bat71 View Post
    what do I need to add to this line?

    arr = Split([r1], ",")
    arr = Split(Worksheets("OtherSheetName").[R1], ",")
    or
    arr = Split(Worksheets("OtherSheetName").Range("R1").Value, ",")

    Quote Originally Posted by Bat71 View Post
    Also, I can only seem to add two (wildcard) keywords for some reason, any more than that and the search stops working
    With this method, you can filter up to two words.


    ..::Edit

    You can also use the advanced filter. On the example given by 76 1976:
    1. F1 cell - empty!
    2. in F2 - F4 consecutively
     = FIND ("RI", A2)
    = FIND ("CO", A2)
    = FIND ("TT", A2)
    Do not worry about the fact that formulas return an error.
    3. Define an advanced filter, as a range of criteria to indicate F1: F4.


    Note, the FIND function is case-sensitive! ::..

    Artik
    Last edited by Artik; 06-06-2019 at 08:08 AM.

  17. #17
    VBAX Regular
    Joined
    Jun 2019
    Posts
    10
    Location
    Thanks, is there a workaround for more than 2?

  18. #18
    VBAX Mentor
    Joined
    Dec 2008
    Posts
    404
    Location
    Read my Edit above

    Artik

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •