• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Query on Advanced filter

Raja0412

New Member
Hi All,

Myself raj, I am new to VBA codes. I got "Runtime error 449" for below code. can you please help me

===============================
Code:
Sub FilterDataraja()

Sheets("Sheet1").Range("A1:L15").AdvancedFilter
Action = xlFilterCopy
CriteriaRange = Sheets("Sheet1").Range("O2:AB3")
CopyToRange = Sheets("Sheet2").Range("B7")
Unique = True
 
End Sub
=========================

Thanks, Raj
 
Last edited by a moderator:
Missing commas between the arguments of AdvancedFilter. Also, line breaks need a " _" after them to show the code continues. Finally, when listing out argument names, you use ":=", not just "=".

Cleaned code:

Code:
Sub FilterDataraja()
   
    Sheets("Sheet1").Range("A1:L15").AdvancedFilter _
        Action:=xlFilterCopy, _
        CriteriaRange:=Sheets("Sheet1").Range("O2:AB3"), _
        CopyToRange:=Sheets("Sheet2").Range("B7"), _
        Unique:=True
End Sub
 
Back
Top