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.
Thank you.
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: