+ Reply to Thread
Results 1 to 8 of 8

Creating a wildcard query for multiple columns of data

  1. #1
    Registered User
    Join Date
    12-03-2012
    Location
    NYC
    MS-Off Ver
    Excel 2003/7
    Posts
    6

    Creating a wildcard query for multiple columns of data

    I have leveraged information from here before, and am now a proud member. I look forward to contributing to this community. Please see below for my current issue. Thank you.

    I would like to create a wildcard query function within a separate worksheet but in the same workbook. I would enter the num/string into the query cell and then the results would list every ROW that contained that wildcard value.

    For instance: The table below would hold the data, and then on the worksheet with the query function I would enter Bird, and get back all the rows with Bird in it.


    A | B | C

    1. Cat | Dog | Bird

    2. Bird| Fish| Bat

    3. Hat | Bat | Ball

    4. Red | Tan | Green


    Query: "Bird"

    Result: Rows #1 & 2

    Cat | Dog | Bird

    Bird| Fish | Bat


    Query: "Bat"

    Result: Row #2

    Bird| Fish | Bat


    Query: 'b' (not case sensitive)

    Result: Row #1, 2, & 3

    Cat | Dog | Bird

    Bird| Fish| Bat

    Hat | Bat | Ball


    I greatly appreciate any/all the support you can provide. Please bear in mind that I am in the process of getting the rust off of the VBA skills, but look forward to tackling this. Thank you.

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Creating a wildcard query for multiple columns of data

    Joecruz749,

    Welcome to the forum!
    Attached is an example workbook based on the criteria you described.
    It contains two worksheets: 'Query' (where the query cell is contained and the results will be displayed) and 'Data' (where the table of data is located)
    In sheet 'Query', cell B2 is where you enter the text that will be searched for. The results will begin in A5 and go down from there. There is a button labelled "Get Results" which is assigned to the following macro:
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Registered User
    Join Date
    12-03-2012
    Location
    NYC
    MS-Off Ver
    Excel 2003/7
    Posts
    6

    Re: Creating a wildcard query for multiple columns of data

    tigeravatar,

    This is exactly what I need. Thank you very much for example, I greatly appreciate it. I love the excelforum, thank you for the warm welcome!!!

    Im going through your code, and was wondering what would I have to modify to make the macro exact and not wildcard? Having both functions would be very useful for the xls. Thank you.

  4. #4
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Creating a wildcard query for multiple columns of data

    @ tigeravatar,

    Very nice!

    I would add:

    Please Login or Register  to view this content.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  5. #5
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Creating a wildcard query for multiple columns of data

    Quote Originally Posted by Joecruz749 View Post
    what would I have to modify to make the macro exact and not wildcard?
    Remove the asteriks from the Set rngFound = lines (note that there are two of them):
    Please Login or Register  to view this content.

    @Winon, great suggestion! I like that, makes the interface a bit cleaner

  6. #6
    Registered User
    Join Date
    12-03-2012
    Location
    NYC
    MS-Off Ver
    Excel 2003/7
    Posts
    6

    Re: Creating a wildcard query for multiple columns of data

    @Winon...thank you for the finishing touch!

    @tigeravatar...thank you, I appreciate it.

    ...I love this place!

  7. #7
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Creating a wildcard query for multiple columns of data

    You're very welcome

    If that takes care of your need, please mark this thread as solved.
    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:
    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

  8. #8
    Valued Forum Contributor
    Join Date
    03-17-2007
    Location
    Michigan
    MS-Off Ver
    Excel 2016
    Posts
    957

    Re: Creating a wildcard query for multiple columns of data

    See if this might work...it has a wildcard search capability (*). It works better if there isn't empty rows of data though.
    Attached Files Attached Files

+ 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.6.0 RC 1