• 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.

Advanced Filter - VBA code

vinu

Member
Hello Team,


How do I use advanced filter in vba code. code should select all the data and put advance filter and conditon(i listed in sheet2 a1:d4 including heading) after filtering the same it should delte the same filtered rows by visible cells (make sure it should not delte the heading). and code should ends with normal view(with out filter.


Thanks,

Vin.
 

Hui

Excel Ninja
Staff member
Vinu

In VBA


Data_Range.AdvancedFilter xlFilterCopy, Criteria_Range, Filtered_Range


Data_Range is the range of your source data including heading

eg: A1:F1000 or a dynamic range etc


Criteria_Range is a range which includes your criteria and values that apply to that

eg:

[pre]
Code:
Age    Name   Year
10     Fred   1963
[/pre]
Filtered range is a Range which has a list of the Fields you want returned

eg: Age Name Year etc etc in a single row


Example

[data].AdvancedFilter xlFilterCopy, [crit], [filtered]

data, crit and filtered are named ranges


or

Range("A1:D1000").AdvancedFilter xlFilterCopy, range("g1:J2"), Worksheets("Sheet2").Range("A1:D1")
 
Top