Hello,
I've been scouring the internet on how to create a search textbox with a clear button that will search one column in my table that has numerical data and filter the table for that. I keep running into issues with it not working for numbers or not being able to clear the search box or not working at all. As you can see, I did try to use a helper column to store the number as text but it wouldn't run.
The last iteration that did work somewhat (only worked for letters, but need it to work for numbers as data will be numbers:
This is what I was hoping to get working, with a clear button that would clear the filters and clear the textbox, but it doesn't work:
Here's my spreadsheet:
I've been scouring the internet on how to create a search textbox with a clear button that will search one column in my table that has numerical data and filter the table for that. I keep running into issues with it not working for numbers or not being able to clear the search box or not working at all. As you can see, I did try to use a helper column to store the number as text but it wouldn't run.
The last iteration that did work somewhat (only worked for letters, but need it to work for numbers as data will be numbers:
VBA Code:
Private Sub TextBox1_Change()
Application.ScreenUpdating = False
ActiveSheet.ListObjects("ScreenLog").Range.AutoFilter Field:=2, Criteria1:=[C2] & "*", Operator:=xlFilterValues
Application.ScreenUpdating = True
End Sub
This is what I was hoping to get working, with a clear button that would clear the filters and clear the textbox, but it doesn't work:
VBA Code:
Sub ClearSearch_Click()
Range("C2").Select
Selection.ClearContents
ActiveSheet.ListObjects("ScreenLog").Range.AutoFilter Field:=13
End Sub
Sub TextBox1_Change()
Application.ScreenUpdating = False
ActiveSheet.ListObjects("ScreenLog").Range.AutoFilter Field:=13, Criteria1:="*" & [C2] & "*", Operator:=xlFilterValues
Application.ScreenUpdating = True
End Sub
Here's my spreadsheet:
Screening Log.xlsm | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | M | N | |||
1 | ||||||||||||||||
2 | ||||||||||||||||
3 | ||||||||||||||||
4 | Name | Mon/Yr of Birth | ||||||||||||||
5 | Screen ID | ID Number | First | Last | Initials | Month | Year | Acronym | Employee Name | Date of Approach | Agreed | If yes, Actual ID | ID as Text | |||
6 | S001 | 15387 | 1 | 5 | 15387 | |||||||||||
7 | S002 | 5486745 | 2 | 5 | 5486745 | |||||||||||
8 | S003 | 156 | 2 | 5 | 156 | |||||||||||
9 | S004 | 158 | 158 | |||||||||||||
10 | S005 | 150045 | 150045 | |||||||||||||
11 | S006 | 4 | 4 | |||||||||||||
12 | S007 | 15264 | 15264 | |||||||||||||
Sheet1 |
Cell Formulas | ||
---|---|---|
Range | Formula | |
N6:N12 | N6 | =LET(x, [@[ID Number]], IF(x=0, "", x)) |