I have been trying to make/create a search box.
My dream scenario would be a dynamic search box that could actually look for what is inputted with in the given table and then filter on all columns. And when the search box is empty all and any filters needs to be removed or cleaned up and that is why I have written my code within a if function.
I have been searching and watching videos for 8 days (well at night time after work) googling and searching even on different questions (with or without answers) here, it doesn't seem possible to search for more then one Field at the time? (Or is it, if so how do I archive this?)
My first field with in my table (the entire column and all the cells) will always contain numbers and this will never change, the second column will not contain anything, but when the cells have any value (usually text) I need to search for even these values. Me changing the code and liking to field 1 doesn't work at all and gives error and also since field one is just numbers the search box seem to be wanting searching on exact numbers even though I have tried to code this with wildcards.
Also what I have written so far give me errors I cant get my head around, I get 'Object is needed' on a popup window and then under the local window, 'Me' and 'WS' without actual value in under value filed/column.
The TextBox1 is of curse set on 'Change' and cell is linked to A9.
another update to the question and problem, when the Else function gets activated (this is when I remove input from box) the the table heads looses those click buttons (those that can used to manually filter/sort with), this is a massive issue and I cant understand what I'm doing to provoke this unwanted outcome.
Would apricate some help on this subject.
Private Sub TextBox1_Change()
Dim ws As Worksheet
Set ws = ThisWorkbook.ActiveSheet
Application.ScreenUpdating = False
If Range("A9").Value <> "" Then
ws.ListObjects("PR11_P3_Tabell").Range.AutoFilter Field:=2, Criteria1:="*" & [A9] & "*", Operator:=xlFilterValues
Else
ws.ListObjects("PR11_P3_Tabell").Range.AutoFilter.ShowAllData
End If
Application.ScreenUpdating = True
End Sub
