excel Vba dynamic filter help

cizzett

Board Regular
Joined
Jan 10, 2019
Messages
121
OK Excel gurus,
I have a spreadsheet I want to use a text box change event to dynamically filter the table by the data in the text box as it is entered.

Also I would prefer if it searched through all the table columns so I can search using different data points and still find it hopefully without having to make a search box for each column.

Here is what I am trying now but keeps erroring out on me.

Advice greatly appreciated.

Code:
Private Sub SearchBox_Change()Dim BCST As ListObject
Dim BS As Worksheet
Set BS = ThisWorkbook.Sheets("Blind Count")
Set BCST = BS.ListObjects("BCST")




If Len(SearchBox.Value) = 0 Then
    BCST.AutoFilterMode = False
    Else
    If BCST.AutoFilterMode = True Then
    BCST.AutoFilterMode = False
    End If
    BCST.DataBodyRange.AutoFilter , "&textbox1.Value&"
End If


End Sub
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
You would need to loop through the columns for this to even have a chance of working.

You will most likely encounter problems with what you're attempting. The most obvious being the wrong column(s) being filtered when common values are found.

The red bits need deleting "&textbox1.Value&"
As you have it, you're looking for what is between the double quotes, not what is typed into the box.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,817
Messages
6,181,149
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top