我有下面的VBA,它循环遍历array()公式中的所有命名选项卡。我希望它是一个动态范围,而不是将值键入数组(),它引用工作表中具有这些值的范围,并在我添加更多时动态
Sub Filter_To_Send()
Dim WshtNames As Variant
Dim WshtNameCrnt As Variant
WshtNames = Array("RASC", "RSUV", "SBKP", "RGRN", "SBTK", "RWAS", "RABT", "RHAY", "RLEX", "RARM", "RBCK", "RBER", "RCCP", "RDAL", "RHEB", "RSST", "RMST", "RMIA", "REHV", "RNBY", "RNOF", "RUTC", "RSCS", "RSJO", "RSCQ", "RSHA", "RAWP", "SART", "SASK", "SALC", "SNHQ", "SOEX", "SPHL", "SSHP", "SMRN")
For Each WshtNameCrnt In WshtNames
With Worksheets(WshtNameCrnt)
.Range("A5").AutoFilter field:=16, Criteria1:="<>0"
End With
Next WshtNameCrnt
End Sub
谢谢!
答案 0 :(得分:1)
如果工作表列表名称“Config”存储在A1:
开始Sub Filter_To_Send()
Dim c As Variant
Dim rngSheets As Range
With Sheets("Config")
Set rngSheets = .Range(.Range("A1"), .Cells(.Rows.Count, 1).End(xlUp))
End with
For Each c In rngSheets.Cells
With Worksheets(c.Value)
.Range("A5").AutoFilter field:=16, Criteria1:="<>0"
End With
Next c
End Sub