fixing problem autofilter

abdelfattah

Well-known Member
Joined
May 3, 2019
Messages
527
Office Version
2010
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
 

Some videos you may like

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
38,993
Office Version
365
Platform
Windows
You're filtering column C for the value of 4, hence nothing shows.
 

abdelfattah

Well-known Member
Joined
May 3, 2019
Messages
527
Office Version
2010
hi, Fluff
so you say the same first number in three rows how i can change that to make in the last three numbers because of them are different
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
38,993
Office Version
365
Platform
Windows
I'm afraid I haven't got a clue what you are saying.
 

abdelfattah

Well-known Member
Joined
May 3, 2019
Messages
527
Office Version
2010
if you mean the number 4 is existed in the same theses code 459730901,466316086,466157997 i'm talking about the first number in theses code

i changed the first number in theses code to become this 459730901,566316086,666157997 not happen any thing this the same problem
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
38,993
Office Version
365
Platform
Windows
You are filtering on column C which does not have any numbers, just names.
 

abdelfattah

Well-known Member
Joined
May 3, 2019
Messages
527
Office Version
2010
also i changed filtering in column b i changed this
from
VBA Code:
Range("$A$3:$m$" & LastRow).AutoFilter field:=3, Criteria1:= _
to
Code:
Range("$A$3:$m$" & LastRow).AutoFilter field:=2, Criteria1:= _
this is the same problem no change anything
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
38,993
Office Version
365
Platform
Windows
Ok, try it like
VBA Code:
   Range("A3:M" & LastRow).AutoFilter 2, ">=400000000", xlAnd, "<=499999999"
 

abdelfattah

Well-known Member
Joined
May 3, 2019
Messages
527
Office Version
2010
not completely it comes the only first code if i search another number it stays the first code just this number 459730901
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
38,993
Office Version
365
Platform
Windows
VBA Code:
   Range("A3:M"&lastrow).AutoFilter 6, ">=" & ActiveSheet.TextBox1.Text * 100000000, xlAnd, "<" & (ActiveSheet.TextBox1.Text + 1) * 100000000
 

Watch MrExcel Video

Forum statistics

Threads
1,096,187
Messages
5,448,861
Members
405,535
Latest member
KLFT

This Week's Hot Topics

Top