• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA Filtering for 3 columns

ToRaDoYa

New Member
Good Day

How to edit this code to make it filter 3 columns instead of 1 column

Code:
ActiveSheet.ListObjects("Table2").Range.AutoFilter Field:=2, Criteria1:="*" & [k3] & "*", Operator:=xlFilterValues


as you can see
Code:
Field:=2
i can only put one column to filter

please how to edit it?
 
ToRadDoYa

Firstly, Welcome to the Chandoo.org Forums

Code:
Selection.AutoFilter
  ActiveSheet.Range("$B$2:$D$100").AutoFilter Field:=1, Criteria1:=">1", Operator:=xlAnd
  ActiveSheet.Range("$B$2:$D$100").AutoFilter Field:=2, Criteria1:="3", Operator:=xlAnd
  ActiveSheet.Range("$B$2:$D$100").AutoFilter Field:=3, Criteria1:="<4", Operator:=xlAnd
 
its not working,, maybe i didn't explain my problem very well , i created a TextBox using Macro and i'm using this code to filter the data whenever i write something inside the Textbox , the problem i need to filter 3 Fields

Capture.png


Capture.png

Code:
ActiveSheet.ListObjects("Table2").Range.AutoFilter Field:=3, Criteria1:="*" & [k3] & "*", Operator:=xlFilterValues


thank you for your time ,, please help
 
Hi !

So it is not filtering as each column needs a specific criteria …

Better to understand with a crystal clear explanation
with samples of criterias and results !

If it is really a filter, why don't you use directly filter of list object
(table yet created in worksheet) ? No code needed …

In case of a search, use an advanced filter with "or" criterias.
 
Back
Top