Hi,
I have a spreadsheet where I would like to search through Column B in order to display the rows which have the information i typed in.
For example, I have a column with , "1357, 1113, 9288, 1209, 2139"
and I type in "13" in the activex textbox, It will only display the rows with
1357
1113
2139
All is working well with this code, but the problem is that it searches through column A instead of B,
Now, If it change the Field to 2, would that allow me to search through column B instead?Private Sub TextBox1_Change() Set txt = TextBox1 Range("A5:E5").AutoFilter Field:=1, Criteria1:="=*" & txt & "*", Operator:=xlAnd End Sub
I get the error:
Run-time error '1004':
AutoFilter method of Range class failed, and the highlighted line is
Please help me out if you can! It's my first time using VB =)Range("A5:E5").AutoFilter Field:=2, Criteria1:="=*" & txt & "*", Operator:=xlAnd
Last edited by nostic; 02-07-2012 at 10:46 AM.
That syntax looks correct to me. You may want to put
before it to clear existing filters.Activesheet.autofiltermode = False
Good luck.
thank you for a quick response, works perfectly now =)
My pleasure.
Please do not forget to mark the thread Solved.
Good luck.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks