Hello,
I can filter strings in any column but not numbers in the table.
Can someone help me.
Thans for any helpPlease Login or Register to view this content.
Hello,
I can filter strings in any column but not numbers in the table.
Can someone help me.
Thans for any helpPlease Login or Register to view this content.
Hello. Let's guess:
a) Apparently, you have your TextBox1 "floating" above the active sheet.
b) Via 'LinkedCell', this TextBox1 appears to be linked to cell E3: this is not necessary to articulate the filter.
c) It seems that you write a number in TextBox1 that is part of a number with more digits.
d) The latter means that AutoFilter is not the right tool to filter your list.
e) You have to use the Advanced Filter as follows:
Of course: the displayed VBA code must go in the sheet module.PHP Code:
Option Explicit
Dim tbl As ListObject
Private Sub TextBox1_Change()
Dim C As Range
Set tbl = ListObjects("EmpList"): tbl.Range.AutoFilter
Set C = tbl.DataBodyRange.Find(What:=TextBox1, LookIn:=xlFormulas, LookAt:=xlPart)
If Not C Is Nothing Then
Set C = Intersect(C.EntireColumn, tbl.Range)
[r2:r3] = Application.Transpose(Array(Empty, _
"=IsNumber(Search(" & TextBox1 & ", " & C(2).Address(0, 0, , True) & "))"))
C.AdvancedFilter 1, [r2:r3], , False: [r2:r3].ClearContents
End If
End Sub
Sub clearFilter()
tbl.Range.AutoFilter
End Sub
.
You are always very welcome if you add reputation by clicking the * (bottom left) of each message that has helped you.
Hello,
Your guess is correct. Code works only if numeric search. I also like to search for string value. Can you modify the code so I can filter by first, last name and dept.
Include is an attached sample.
Thanks
For example like this:
Hello Mr beyond,
I did some testing today and code work nicely. I added an extra column for Dates and try to search but no results.
I used the IsDate in your code but is giving me an error. I see you check for a number using the IsNumber that I requested earlier.
So how can you also check for dates and then filter the date column. I was thinking of using a different sheet just for searching.
This way I can print the results for multiple pages. Any idea how to filter by dates in your demo.
Thanks for your help.
.
While I'm thinking about how to do it, don't forget to 'click' the * at the bottom-left of post #4.
When searching for dates, will you be looking for a specific date or a range of dates?
Good morning Mr Beyond
I would like to search for a range of dates. I added a * for post #4 and put a nice comment.
Thanks
Hello. Analyze this new data configuration:
PHP Code:
Option Explicit
Dim tbl As ListObject
Sub applyFilter()
ListObjects("EmpList3").Range.AdvancedFilter 1, [c1].CurrentRegion.Rows("1:2"), , False
End Sub
Sub clearFilter()
ListObjects("EmpList3").Range.AutoFilter: ActiveCell.Activate
End Sub
Perfect, Thanks beyond excel.
Thank you very much.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks