fixing problem autofilter

abdelfattah

Well-known Member
Joined
May 3, 2019
Messages
1,429
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
hello
i need help about my code when i search by code in textbox it doesn't show anything
this is my data
1.JPG


the problem when i write in textbox number of code
2.JPG



VBA Code:
Private Sub TextBox1_Change()
Dim LastRow As Long
LastRow = Range("b1000").End(xlUp).Row
If ActiveSheet.TextBox1.Text <> "" Then
Range("$A$3:$m$" & LastRow).AutoFilter field:=3, Criteria1:= _
"=" & ActiveSheet.TextBox1.Text & "*", Operator:=xlOr
Else
Range("A3:m3").AutoFilter
Range("A3:m3").AutoFilter
End If
End Sub
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Change the field to 2, I forgot to change it.
 
Upvote 0
when i write the first number the code works but when i complete the rest of numbers it disappears whole
 
Upvote 0
Suggestion.
Please explain EXACTLY what you are trying to do, rather than feed us little bits.
 
Upvote 0
i would filter after write the first three numbers not the first number
 
Upvote 0
In that case simply remove the last 2 0s from the 100000000
 
Upvote 0
this is my current code
VBA Code:
Private Sub TextBox1_Change()
Dim LastRow As Long
LastRow = Range("b1000").End(xlUp).Row
If ActiveSheet.TextBox1.Text <> "" Then
     Range("A3:M" & LastRow).AutoFilter 2, ">=" & ActiveSheet.TextBox1.Text * 1000000, xlAnd, "<" & (ActiveSheet.TextBox1.Text + 1) * 1000000
Else
Range("A3:m3").AutoFilter
End If
End Sub
 
Upvote 0
That works for me, did you put 3 digits into the textbox before running the code?
 
Upvote 0

Forum statistics

Threads
1,214,593
Messages
6,120,435
Members
448,961
Latest member
nzskater

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