• 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 code for multiple criteria

Hi,

Need help with my code below:

ActiveSheet.Range("$A:$S").AutoFilter Field:=1, Criteria1:=Array( _
Worksheets(2).Range("A2").Value), Operator:=xlFilterValues

Worksheets(2).Range("A2").Value = "1","2","3"

This doesn't filter the 1,2,3 from the cell A2.


But when i go with below code it filter the set of range with the criteria.

ActiveSheet.Range("$A:$S").AutoFilter Field:=1, Criteria1:=Array( _
"1","2","3"), Operator:=xlFilterValues

why cant i filter it when i use it with cell value ?
 
try:
Code:
Worksheets(2).Range("A2").Value = "1,2,3"
ActiveSheet.Range("$A:$S").AutoFilter Field:=1, Criteria1:=Split(Worksheets(2).Range("A2").Value, ","), Operator:=xlFilterValues
 
Back
Top