VBA Code to auto filter as you type for numbers

luisftv

New Member
Joined
Nov 17, 2018
Messages
7
Can this code be modified to auto filter numbers?

I am using a button to input the number I am looking for.

This code works perfectly as long as it handles text and I can't find the way to handle a column that has only numbers. This column will only have whole numbers (1, 2, 4, 200, 1000, etc.). The column cell properties is set to General and it must stay as General or Number.

VBA Code:
Private Sub TextBox4_Change()
TextBox4.Font.Size = 14
Dim xStr, xName As String
Dim xWS As Worksheet
Dim xRg As Range
    On Error GoTo Err01
    Application.ScreenUpdating = False
    xName = "Techlog"
    xStr = TextBox4.Text
    Set xWS = ActiveSheet
    Set xRg = xWS.ListObjects(xName).Range
    If xStr <> "" Then
        xRg.AutoFilter Field:=5, Criteria1:="*" & xStr & "*", Operator:=xlFilterValues
    Else
        xRg.AutoFilter Field:=5, Operator:=xlFilterValues
    End If
Err01:
Application.ScreenUpdating = True
End Sub

Thank you.
 
Last edited:

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,916
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
As you should know by now:

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: Auto Filter as you type for numbers with VBA
If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 

luisftv

New Member
Joined
Nov 17, 2018
Messages
7
Oh, I knew I had forgotten something. I apologize for that. I seldom use forums (I know this does not excuse me) and going back to work has been very busy that we sometimes don't have time even for lunch (our schools have been closed for more than a year so you can imagine - dust, malfunctioning equipment, training staff, etc etc).

FOR THE RECORD:

This same question/problem is also being discussed at this other forum but has render only partial solutions:

Excel Forum: Auto Filter as you type for numbers using VBA

I hope some one can help convert the code above to be able to handle numbers.

Thanks again.
 

sintek

New Member
Joined
Oct 14, 2015
Messages
39

ADVERTISEMENT

A solution snippet to do this has already been supplied in the other forum...Post 37
 

sintek

New Member
Joined
Oct 14, 2015
Messages
39
This is where I started off...Was lead to focus elsewhere though...Hence only New Member status...
 

Watch MrExcel Video

Forum statistics

Threads
1,132,640
Messages
5,654,541
Members
418,139
Latest member
nimesh72

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
Top