• 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.

Select a Named Range within the AutoFilter code

waynewalker

New Member
I am selecting a worksheet and then turning on the AutoFilter. I am then filtering the column on the specific number highlighted in red below.

What I would like to do is replace that specific number with a named range. Is that possible?

Code:
Sheets("MSO").Select
  Range("E6").Select
  ActiveSheet.AutoFilterMode = False
  Selection.AutoFilter
  ActiveSheet.ListObjects("MSO").Range.AutoFilter Field:=6, Criteria1:= _
     [COLOR=#ff0000]"5303030"[/COLOR]
  Range("MSO[[Column2]:[Column2]]").Select
  Selection.Copy
__________________________________________________________________
Mod edit : thread moved to appropriate forum !
 
Last edited by a moderator:
Yes. You'd need to transpose named range (single column) and specify Operator.

So if named range is named "lstcrit1"... something like below.
Code:
Sub test()

With Sheets("MSO")
    If .AutoFilterMode Then .ShowAllData
    .ListObjects("MSO").Range.AutoFilter Field:=6, _
        Criteria1:=Application.Transpose(Range("lstcrit1")), _
        Operator:=xlFilterValues
End With
End Sub
 
Back
Top