+ Reply to Thread
Results 1 to 22 of 22

Search using wildcard

  1. #1
    Forum Contributor
    Join Date
    11-13-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    464

    Search using wildcard

    Hello,
    I'm trying to perform a search of over 15,000 entries using a wildcard. Sheet1 is a list of streets in the county where I live, and I would like to be able to type a part of the name that will return every instance of that name appearing.

    I found a code which i have tried to adapt, but it is not working.
    Please Login or Register  to view this content.
    The item being searched will be entered into TextBox1, and I'm guessing that the error I am receiving is in the .AutoFilter Field:=1, Criteria1:=TextBox1"*" line of code. This is the original sample I found onlne:

    Please Login or Register  to view this content.
    where they were only looking for the letters "GB"

    Can anyone help?

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: Search using wildcard

    Haven't tested, but did you try
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    11-13-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    464

    Re: Search using wildcard

    I have not.

  4. #4
    Forum Contributor
    Join Date
    11-13-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    464

    Re: Search using wildcard

    Please Login or Register  to view this content.
    I modified it a bit, and what is happening is that it is taking the header row A1:N1 and transferring the header to Sheet 1. I cannot attach the file because it is not "For Public Display"

    I should add that this search will likely generate multiple results. This search is designed to help people find a street when they only have a part of the name, so if the user enters "wood" into the Textbox, I would like all of the results from Column A containing "wood" to appear on sheet 2.
    Last edited by tapsmiled; 07-29-2014 at 06:41 PM.

  5. #5
    Forum Contributor
    Join Date
    11-13-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    464

    Re: Search using wildcard

    I changed the Copy Destination to Range("A:A") and it populated Sheet 1 with the header in every row for thousands of rows.

  6. #6
    Forum Contributor
    Join Date
    02-24-2013
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Search using wildcard

    You were really, really close.

    In addition to Paul's suggestion, change this;
    Please Login or Register  to view this content.
    to this;
    Please Login or Register  to view this content.
    Last edited by Jim885; 07-29-2014 at 06:59 PM.
    If I helped in any way, please click the star

  7. #7
    Forum Contributor
    Join Date
    11-13-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    464

    Re: Search using wildcard

    Please Login or Register  to view this content.
    I tried that last suggestion, and now I'm back to the entire header row being printed on Sheet 1 and nothing going onto Sheet 2.
    Last edited by tapsmiled; 07-29-2014 at 07:27 PM.

  8. #8
    Forum Contributor
    Join Date
    11-13-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    464

    Re: Search using wildcard

    okay, I've found a few issues. #1: I'm dumb. The road names are in B and not A. #2 in the Copy Destination, it is listing Sheet 2 ("A1"). First, nothing is transferring to Sheet 2; everything is going to Sheet 1. Second, does the "A1" limited the responses to only 1? Would it have to be "A:A" so that all of the responses returned by the query will go into the A column and not a single field?

    Forgive me, I'm completely naive to this type of action, so I don't have a grasp on the logic.

  9. #9
    Forum Contributor
    Join Date
    02-24-2013
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Search using wildcard

    Take note of the changes below;
    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    02-24-2013
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Search using wildcard

    Some info;

    Your modified code had this;
    Please Login or Register  to view this content.
    Your data is in colomn B so the search has to be in column B. Not columns A1 through the last row of column B (as your code was written). That was a typo/oversight on your part.
    So, this is the correction that I have in the code I provided;
    Please Login or Register  to view this content.
    Secondly, since you are now filtering Column B, The AutoFilter Field needed to be changed from Field:=1 to Field:=2

  11. #11
    Forum Contributor
    Join Date
    11-13-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    464

    Re: Search using wildcard

    Oh man, you're awesome!!! Can you alter it so that I am only seeing columns A:E when the results are populated? It is showing the entire row, and because the document has so much in it, it runs a little slow. I also added a "*" before TextBox1 so that it will search for all versions of the word.

    I changed the A1:N to A1:E and it didn't limit the search to my above specifications.

  12. #12
    Forum Contributor
    Join Date
    02-24-2013
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Search using wildcard

    Change this;
    Please Login or Register  to view this content.
    to this;
    Please Login or Register  to view this content.

  13. #13
    Forum Contributor
    Join Date
    11-13-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    464

    Re: Search using wildcard

    Thanks man! I actually came up with a different method that accomplished the same thing. Thank you very much!!!!! Believe it or not, this may actually, one day, help to save a life. No kidding.

  14. #14
    Forum Contributor
    Join Date
    11-13-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    464

    Re: Search using wildcard

    Sorry...one last question. I placed a command button on Sheet 3, where my data appears. What could I put to clear all of the cells after the search has been completed?

  15. #15
    Forum Contributor
    Join Date
    02-24-2013
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Search using wildcard

    I wasn't too keen on the code you had, and saw a few small improvements that I thought were needed. So, here's the complete version of the code I did for you.
    Please Login or Register  to view this content.


    You're welcome. Please mark this thread as Solved, and please leave a Rep for me! Thanks.
    Last edited by Jim885; 07-29-2014 at 09:23 PM.

  16. #16
    Forum Contributor
    Join Date
    02-24-2013
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Search using wildcard

    Quote Originally Posted by tapsmiled View Post
    Sorry...one last question. I placed a command button on Sheet 3, where my data appears. What could I put to clear all of the cells after the search has been completed?
    That would be;
    Please Login or Register  to view this content.

  17. #17
    Forum Contributor
    Join Date
    11-13-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    464

    Re: Search using wildcard

    Marked as solved and repped already!!! LOL Can you explain the differences with the new code. This other one is perfect.

  18. #18
    Forum Contributor
    Join Date
    11-13-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    464

    Re: Search using wildcard

    Would that clear my header too?

  19. #19
    Forum Contributor
    Join Date
    02-24-2013
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Search using wildcard

    To prevent the headers from being cleared, you will need this;
    Please Login or Register  to view this content.
    Whereas, Z is the last column that I guessed where your data extends to. You can change the value of Z to whatever suits the last column of your data.




    The line;
    Please Login or Register  to view this content.
    will prevent the screen from flickering when as the code runs.
    After the code completes, the last line;
    Please Login or Register  to view this content.
    allows the screen to refresh.

  20. #20
    Forum Contributor
    Join Date
    11-13-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    464

    Re: Search using wildcard

    I'm gonna try it. This is going to be such a useful tool. If you don't mind, one last question...

    Is there a way to highlight the letters? If the word "fern" is searched, it would be great if "fern" had a yellow fill color just around those letters since the wildcard is before and after the entry. You have really helped me immensely. I may pick your brain on another project that is unresolved.

  21. #21
    Forum Contributor
    Join Date
    02-24-2013
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Search using wildcard

    With code, there is always a way to do something.

    I ask you to start a new topic on your latest question. That way, if someone else has the same question/needs the same answer, they can look it up online, by topic.

    Thanks!

  22. #22
    Forum Contributor
    Join Date
    11-13-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    464

    Re: Search using wildcard

    Will do! Thanks again!

+ 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] Wildcard Search
    By yccyccycc in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-12-2013, 02:22 AM
  2. If, And, wildcard search
    By zachvu in forum Excel General
    Replies: 4
    Last Post: 07-14-2011, 06:41 PM
  3. Wildcard search using vlookup
    By hammer180 in forum Excel General
    Replies: 6
    Last Post: 07-08-2011, 04:35 PM
  4. Excel 2007 : search data using wildcard and sum it
    By eddy82 in forum Excel General
    Replies: 1
    Last Post: 06-03-2010, 06:23 AM
  5. Wildcard search for IF command
    By Zyphon in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-19-2008, 05:00 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