+ Reply to Thread
Results 1 to 35 of 35

Dynamic Search Box in Excel

  1. #1
    Valued Forum Contributor
    Join Date
    02-07-2013
    Location
    Philippines
    MS-Off Ver
    Excel Online; 365
    Posts
    610

    Dynamic Search Box in Excel

    Hi Experts,

    How can i create a dynamic search box which will display all the rows that have the data that is being search (it can be dynamic as i type or after pressing the search button).

    Say I put in "Knife" in the search box... it should show all the rows with the word "Knife" in it.

    The Search Table is within column B:L and is continuously updated.

    Your help is greatly appreciated.
    If I've helped U pls click on d *Add Reputation

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,962

    Re: Dynamic Search Box in Excel

    The easiest way is to use a column of formulas, like this in M2, with 'knife' in M1:

    =NOT(ISERROR(MATCH("*" &$M$1&"*",B2:L2,FALSE)))

    Then copy down and filter on column M to show TRUE values. You can use a macro to do all that but it is just as easy to enter the value into M1 and use Data filters.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,486

    Re: Dynamic Search Box in Excel

    Here is a thread on autofilter as you type and a webpage
    -
    AutoFiler as you type thread
    -
    http://www.xlorate.com/excel-questio...s%20you%20Type

    -
    I also have a horrible vid, I think I will make a new one, hard to hear anything
    My Vid
    Last edited by davesexcel; 12-03-2018 at 11:25 AM.

  4. #4
    Valued Forum Contributor
    Join Date
    02-07-2013
    Location
    Philippines
    MS-Off Ver
    Excel Online; 365
    Posts
    610

    Re: Dynamic Search Box in Excel

    Thanks for the thread davesexcel.. Really informative.. unfortunately i can't seem to make it work with my own table..

    what i would like to do it type in a text in the search box and excel will look into the entire table of data...

    then it will display all rows that have the text/data in any of the cells in the row...

    I've attached a sample worksheet.. what i would like to do is be able to search thru the entire table..so even if i type Blue the table will display rows with the word Blue
    Attached Files Attached Files

  5. #5
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Dynamic Search Box in Excel

    Your code adapted seems to work:

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  6. #6
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,486

    Re: Dynamic Search Box in Excel

    Sure thing,
    Check it out.


    Please Login or Register  to view this content.

  7. #7
    Valued Forum Contributor
    Join Date
    02-07-2013
    Location
    Philippines
    MS-Off Ver
    Excel Online; 365
    Posts
    610

    Re: Dynamic Search Box in Excel

    Thank you, XLAdept unfortunately can't get your code to work..

    What i'm looking for is the ability to filter the table by any search item. So even if i type in Ben or Blue or 27 in the search box - it would go thru the entire table and display the rows with the corresponding result.

  8. #8
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Dynamic Search Box in Excel

    Oh - my bad! But it looks like davesexcel has solved your problem!

  9. #9
    Valued Forum Contributor
    Join Date
    02-07-2013
    Location
    Philippines
    MS-Off Ver
    Excel Online; 365
    Posts
    610

    Re: Dynamic Search Box in Excel

    yes xladept. thank you davesexcel.. few things can't seem to make your code work on my actual table

    1) my table have 12 columns starting from B4 to M4 down.. there will be empty cells in the entire table.. cells in Column D & E, however will always have data

    2) could i add a button that would clear the search box when click thereby clearing any filters applied

    I notice that the code will cease to work if there are empty cells in the table.. how do i go around that?
    Last edited by bhenlee; 12-03-2018 at 01:46 PM.

  10. #10
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,486

    Re: Dynamic Search Box in Excel

    Attaching a sample workbook enables others to work on your problem:

    To attach a sample workbook. Make sure there is just enough data to make it clear what is needed. Include BEFORE/AFTER sheets if needed to show the process you're trying to complete or automate. Remember to desensitize the data.

    Click on GO ADVANCED and click "manage attachments" to open the upload window.


    To add a file to a post

  11. #11
    Valued Forum Contributor
    Join Date
    02-07-2013
    Location
    Philippines
    MS-Off Ver
    Excel Online; 365
    Posts
    610

    Re: Dynamic Search Box in Excel

    here you go.. i've attached a sample of the worksheet i'm working on...

    Here's what I'm trying to achieve:

    1) Type any search item (Date or any item Code or any Product1 etc) in the search box and display all rows containing the search item

    2) A code to clear the search box and return the table in its unfiltered state
    Attached Files Attached Files
    Last edited by bhenlee; 12-03-2018 at 02:10 PM.

  12. #12
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,962

    Re: Dynamic Search Box in Excel

    Filtering columns does not use OR logic - it uses AND logic. If you want to find all values but in any column, you need to use a helper column for formulas as I posted, or use code to fill a single column with TRUE / FALSE values based on the values in that row.

  13. #13
    Valued Forum Contributor
    Join Date
    02-07-2013
    Location
    Philippines
    MS-Off Ver
    Excel Online; 365
    Posts
    610

    Re: Dynamic Search Box in Excel

    Hi Bernie,

    What I'm trying to say any search item like Boxes or 10% or Gloves or 1234 in the search box... the code will go thru the entire table and display the rows which contains say Boxes...

  14. #14
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,962

    Re: Dynamic Search Box in Excel

    HTML Code: 
    Last edited by Bernie Deitrick; 12-03-2018 at 02:49 PM.

  15. #15
    Valued Forum Contributor
    Join Date
    02-07-2013
    Location
    Philippines
    MS-Off Ver
    Excel Online; 365
    Posts
    610

    Re: Dynamic Search Box in Excel

    Thanks Bernie but it's not working.. is there anyway the code can be used with the search box instead?

  16. #16
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,962

    Re: Dynamic Search Box in Excel

    What do you mean by "it's not working"? Clear all the filters from your sheet and try again - I have assumed that column M is free so make sure you insert a new column M if that is not the case

  17. #17
    Valued Forum Contributor
    Join Date
    02-07-2013
    Location
    Philippines
    MS-Off Ver
    Excel Online; 365
    Posts
    610

    Re: Dynamic Search Box in Excel

    It does not work as intended.. when i run the code and type in the search item and click ok... all rows with data are filtered..

    also is there any way we could use a search box instead?

  18. #18
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,962

    Re: Dynamic Search Box in Excel

    What rows do you want filtered? You just said columns B to L without specifying rows: "The Search Table is within column B:L and is continuously updated."

  19. #19
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,486

    Re: Dynamic Search Box in Excel

    Quote Originally Posted by bhenlee View Post
    here you go.. i've attached a sample of the worksheet i'm working on...

    Here's what I'm trying to achieve:

    1) Type any search item (Date or any item Code or any Product1 etc) in the search box and display all rows containing the search item

    2) A code to clear the search box and return the table in its unfiltered state
    Is this not the same sample you supplied before?

  20. #20
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Dynamic Search Box in Excel

    Try:

    Please Login or Register  to view this content.

  21. #21
    Valued Forum Contributor
    Join Date
    02-07-2013
    Location
    Philippines
    MS-Off Ver
    Excel Online; 365
    Posts
    610

    Re: Dynamic Search Box in Excel

    Thank you xladept and davesexcel. not sure if I'm doing it correctly but i can't seem to get your code to work on the attached file. Your code seems to work on the initial file that i uploaded (only 3 columns).

    One thing about your code - it doesn't work if i enter a number in the search box.

    Really appreciate your time and help guys.
    Attached Files Attached Files

  22. #22
    Valued Forum Contributor
    Join Date
    02-07-2013
    Location
    Philippines
    MS-Off Ver
    Excel Online; 365
    Posts
    610

    Re: Dynamic Search Box in Excel

    Hi Davesexcel - It's a different file just the same filename.. the new file should have columns B:L

  23. #23
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,486

    Re: Dynamic Search Box in Excel

    This seems to work, it will not work for the percentage columns though, possibly a different algorithm would be required.
    I commented out the hide arrow lines as it is not important for the exercise.

    Please Login or Register  to view this content.

  24. #24
    Valued Forum Contributor
    Join Date
    02-07-2013
    Location
    Philippines
    MS-Off Ver
    Excel Online; 365
    Posts
    610

    Re: Dynamic Search Box in Excel

    Thanks Davesexcel.. seems to be in the right direction.. still a few bugs..

    1) when i type in the search box - the filter arrows are moved to row 1 and the column titles are hidden... it only shows the row with the text that was searched for.


    2) I noticed that the code already works if i typed in only part of the number and not the entire number (ex. 1234...) but when text is entered it will not show the result until the entire word is entered as it is shown in the table.. is it possible to do it like even if i just type the letter b it will show results for Bags and Boxes?

    I really appreciate all your time and help..

  25. #25
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Dynamic Search Box in Excel

    Another attempt:

    Please Login or Register  to view this content.
    Last edited by xladept; 12-04-2018 at 01:07 PM.

  26. #26
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,913

    Re: Dynamic Search Box in Excel

    I had done something similar in another forum. This is using Table.

    See if you can adopt this.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  27. #27
    Valued Forum Contributor
    Join Date
    02-07-2013
    Location
    Philippines
    MS-Off Ver
    Excel Online; 365
    Posts
    610

    Re: Dynamic Search Box in Excel

    Thank you xladept....

    Was able to figure things out and your code works perfectly...

    Thank you so much for your time and help!!!
    Last edited by bhenlee; 12-04-2018 at 01:36 PM.

  28. #28
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Dynamic Search Box in Excel

    Are your headers in the first row? If so the newest code should work - it works on the second sample you posted

    (I edited that code a half hour after the original post.)

    And - thanks for the rep!
    Last edited by xladept; 12-04-2018 at 01:39 PM.

  29. #29
    Valued Forum Contributor
    Join Date
    02-07-2013
    Location
    Philippines
    MS-Off Ver
    Excel Online; 365
    Posts
    610

    Re: Dynamic Search Box in Excel

    Yes everything is working as planned

    the rep is just a small token of my appreciation...

    Thank you so much..

  30. #30
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Dynamic Search Box in Excel

    You're welcome!

  31. #31
    Valued Forum Contributor
    Join Date
    02-07-2013
    Location
    Philippines
    MS-Off Ver
    Excel Online; 365
    Posts
    610

    Re: Dynamic Search Box in Excel

    xladept if it isn't asking too much... how do i make your code work on a protected worksheet?

    thank you

  32. #32
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Dynamic Search Box in Excel

    Maybe:

    Please Login or Register  to view this content.
    *You'll need to change the password to the actual password (in red).

  33. #33
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,913

    Re: Dynamic Search Box in Excel

    Or you could allow filters when you protect sheet.
    And unlock cell linked to textbox.

  34. #34
    Registered User
    Join Date
    11-04-2019
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    1

    Re: Dynamic Search Box in Excel

    This one works well.

  35. #35
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Dynamic Search Box in Excel

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

+ 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. advanced search, dynamic search
    By jlara0687 in forum Excel General
    Replies: 0
    Last Post: 09-26-2018, 06:29 PM
  2. [SOLVED] Dynamic search as you type NEED HELP
    By cbterror in forum Excel General
    Replies: 11
    Last Post: 09-15-2018, 02:23 AM
  3. [SOLVED] Dynamic Search
    By morayman in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-06-2015, 04:46 AM
  4. Search mechanasim IN EXCEL with dynamic creteria
    By dipesh4uin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-02-2012, 05:03 PM
  5. Dynamic search to add data
    By spidykwya in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-06-2012, 11:23 PM
  6. Dynamic Search?!
    By memosky in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-05-2007, 12:08 AM
  7. dynamic search
    By Lori in forum Excel General
    Replies: 0
    Last Post: 02-04-2006, 07:45 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