gpt4 book ai didi

VBA Excel : Filter a column

转载 作者:行者123 更新时间:2023-12-04 21:56:27 24 4
gpt4 key购买 nike

我正在尝试像之前多次过滤的那样过滤列。但得到如下错误:

1004: "Autofilter method of Range class failed"


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

关于VBA Excel : Filter a column,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43800280/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com