1

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"

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

1 Answer 1

3

Since the range to be filtered contains only one column, it should be like this...

My_Range.AutoFilter Field:=1, Criteria1:="Won", Operator:=xlFilterValues
Sign up to request clarification or add additional context in comments.

1 Comment

You're welcome Meru! Glad I could help. Please take a moment to accept the answer to mark your question as Solved.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.