简体   繁体   中英

Autofilter with VBA in more sheets

i want to filter in more than one sheet for one specific item eg, "Harry"

My macro does not say that i am wrong, but nothing happens..

Sub New_Marko_for_selection()

Worksheets("Sheet53").Range("A1:D4").AutoFilter,Criteria1:="Harry"

end sub

Best Regards

Here is typical code to apply AutoFilter to several sheets:

Sub New_Marko_for_selection()
    Dim sh As Worksheet

    For Each sh In Sheets(Array("Sheet1", "Sheet3"))
        sh.Range("$A$1:$D$4").AutoFilter Field:=1, Criteria1:="Harry"
    Next sh
End Sub

Note:

  • I specified the column
  • I list the required sheets in the Array()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM