I am trying to make a SearchBox on my excel spreadsheet
Here are some pointers to what i hope to achieve:
- The search should occur as the user types (instant search)
- All rows that contain the search phrase should remain whilst the other rows are hidden
- The search should work with numbers and symbols (not that important - but certainly desirable)
- Highlight the cells that contain the search string
I am also hoping that the code can be integrated into a ribbon textbox control - so that this search system could be set up on the fly for any worksheet - or even better - i would like to add a textbox to a custom ribbon tab that would search the active sheet with the filtering and highlighting. But this may simply be out of my reach
If my explanation is not clear enough - the attached Workbook should give you the basic idea.
The attached Workbook is a prototype - It mostly works - but i know the methods that i used are extremely inefficient, and therefore the code can get VERY slow when there is too much data.
FilterSearchBoxExample.xlsm
I will explain what i have done in this workbook:
i have created 2 sheets. Sheet1 contains the Data and there is a Textbox at cell M2 where the user types in a search string
that textbox is linked to M2, there is a conditional formatting rule that highlights all the cells in the data range that contain a match for the search string.
The second sheet is "SearchFilterX" where i have created a criteria range for an advanced filter. this will be hidden - and just used as a backend for the advanced filter
so basically what happens is the user types something into the textbox the textbox has a macro that writes the search term into the advanced filter critera sheet,
and then - in the same macro - it implements the advanced filter.
This mostly gets me the desired results - but i really need it to work faster -
(please note that it may seem to work OK when you test it - but try adding a thousand rows onto each column and it slows down way too much.)
So i ask the excel guru's out there - please help me perfect this.
Bookmarks