Speed up macro object_ Change()

Celticfc

Board Regular
Joined
Feb 28, 2016
Messages
152
Hi,

I have a "search box" where you can search for a name in my table named "manager1" and it will filter through.

The problem is, it takes ages to filter as my table is 20X700 so it has lots of entries.

Can we add criteria to the code where it will take effect only if user types 5 or more characters?

Any other idea how to speed up?

Thank you.

Code:
Private Sub TextBox1_Change()
    ActiveSheet.ListObjects("manager1").Range.AutoFilter Field:=7, _
        Criteria1:="*" & [az1] & "*", Operator:=xlFilterValues
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
try this:
Code:
Private Sub TextBox1_Change()
s = TextBox1.Value
 If Len(s) > 4 Then
  Private Sub TextBox1_Change()
    ActiveSheet.ListObjects("manager1").Range.AutoFilter Field:=7, _
        Criteria1:="*" & [az1] & "*", Operator:=xlFilterValues
 End If
End Sub
 
Upvote 0
sorry it should be:
Code:
[COLOR=#333333]Private Sub TextBox1_Change()
[/COLOR]s = TextBox1.Value
 If Len(s) > 4 Then
  
    ActiveSheet.ListObjects("manager1").Range.AutoFilter Field:=7, _
        Criteria1:="*" & [az1] & "*", Operator:=xlFilterValues
 End If [COLOR=#333333]End Sub[/COLOR]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,981
Messages
6,122,565
Members
449,089
Latest member
Motoracer88

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