VBA Code to auto filter as you type for numbers

luisftv

New Member
Joined
Nov 17, 2018
Messages
13
Office Version
  1. 2010
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

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
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.
 
Upvote 0
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.
 
Upvote 0
A solution snippet to do this has already been supplied in the other forum...Post 37
 
Upvote 0
This is where I started off...Was lead to focus elsewhere though...Hence only New Member status...
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,693
Members
448,979
Latest member
DET4492

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