[英]VBA Excel: Filter a column
I am trying to filter a column as I had many times earlier. 我正在尝试过滤一个列,就像我之前多次过滤一样。 But getting error as below:
但是得到如下错误:
1004: "Autofilter method of Range class failed"
1004:“Range类的自动过滤方法失败”
Set wkb1 = Workbooks.Open("D:\Meru\Work\Trace Reports\Automation\Macro Codes\" & CFname & "\Daily Pivots -" & CfolderN & ".xls")
With wkb1.Worksheets("winloss")
LastRow5 = .Cells(.Rows.Count, "A").End(xlUp).Row
'MsgBox LastRow
Set My_Range = .Range("V1:V" & LastRow5)
'MsgBox My_Range
My_Range.AutoFilter Field:=22, Criteria1:="Won", Operator:=xlFilterValues
' LastRow = .Cells(.Rows.Count, "G").End(xlUp).Row
.UsedRange.Copy
End With
With wkb1.Worksheets("Trial")
.Range(.Cells(1, "A"), .Cells(LastRow5, "A")).PasteSpecial xlPasteValues
End With
由于要过滤的范围只包含一列,因此它应该是这样的......
My_Range.AutoFilter Field:=1, Criteria1:="Won", Operator:=xlFilterValues
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.