Create Searchbox Using Filter Function Automatically

How to create a searchbox using the Filter function automatically.

Here’s the recorded and cleaned code:

Option Explicit

Sub searchbox()

‘ searchbox Macro
‘ Searchable Drop Down List

Worksheets(“ClientNames”).Range(“C2”) = _
“=FILTER(Table1,ISNUMBER(SEARCH(DataEntry!B2,Table1,1)),””””)”
Sheets(“DataEntry”).Select
Range(“B2”).Select
Selection.ClearContents
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:=”=ClientNames!$C$2#”
.IgnoreBlank = True
.InCellDropdown = True
‘ .InputTitle = “”
‘ .ErrorTitle = “”
‘.InputMessage = “”
‘.ErrorMessage = “”
.ShowInput = True
.ShowError = False
End With

End Sub

Let’s get some more details about the Excel functions Search, Isnumber and Filter.

The SEARCH function has the following syntax:

SEARCH(find_text,within_text,[start_num])

find_text: This parameter is required. This is the text that you want to find.
within_text: This parameter is required. This is the text in which you want to search for the value of the find_text argument.
start_num: This parameter is optional. This is the character number in the within_text argument at which you want to start searching.

The SEARCH function finds one text string within a second text string, and returns the number of the starting position of the first text string from the first character of the second text string. For example, to find the position of the letter “t” in the word “smith”, you can use the following function:
=SEARCH(“t”,”smith”)

This function returns 4 because “t” is the fourth character in the word “smith”.

You can also search for words within other words. For example, the function
=SEARCH(“base”,”database”)
returns 5, because the word “base” begins at the fifth character of the word “database”.

ISNUMBER belongs to the group of ‘IS’ functions which check the specified value and returns TRUE or FALSE depending on the outcome.

For example the syntax of this function is ISNUMBER(value) and ‘value’ refers to a number.

The FILTER function has the following Syntax: FILTER(array, include, [if_empty])

ARRAY: the cells that contain the data.

include – the cells that have the data and the match criteria.

[if_empty] – tells the function what should be displayed if the list does contain the searched items. In our example, it will display a blank or ’empty string’.

Further Reading:

How to use the Excel Filter Function

Published by

Dinesh Kumar Takyar

Welcome to exceltrainingvideos.com! My aim is to help you learn MS Excel including VBA. I always felt that a good way to learn something was to find solutions to problems in that domain. That is why I share these Excel videos with you. Mostly these are questions asked during my corporate training sessions. I've been training individuals and companies in computers since 1991. I did my B. Sc. (Vordiplom), M. Sc. (Diplom) and Ph.D. (Dr. rer. nat.) from Hamburg, Germany. The best thing about solving some of my visitor's questions is that I also gain new insights. For more Excel VBA solutions you may like to visit my YouTube channel: http://youtube.com/familycomputerclub For a structured Excel VBA training course online you can visit: https://www.youtube.com/excelvbaonline

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.