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

Filter Data using Advanced Filter and VBA

gazitaliano

New Member
Hi I'm having a problem filtering data.


I downloaded the 'Extract data using advanced filter with vba' file and have amended the vba code to suit my own workbook, however when I click on my get data button it only copies over the headers from my table, not the data?


This is the code I have:


Sub getdata1()

Sheets("Sheet2").Select

Range("S8").Select

Range(Selection, Selection.End(xlToRight)).Select

Range(Selection, Selection.End(xlDown)).Select

Selection.Clear


Sheets("Sheet1").Range("Table1[#All]").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:= _

Sheets("Sheet1").Range("W1:X2"), CopyToRange:=Sheets("Sheet2").Range("S8"), Unique:=True

Columns.AutoFit

Range("S8").Select

End Sub


Any help would be great. Thanks
 
Right I've tried changing my Criteria to W1:W2 and that worked, Y1:Y2 worked, but for some reason X1:X2 isn't producing any results.
 
Might want to review how the Advanced Filter criteria works, and how the And/Or type logic is calculated.

http://chandoo.org/wp/2011/10/10/how-to-use-advanced-filters/


The code you posted above is looking at all 3 cells, so it's only going to return results here the criteria in W2 and X2 are met at the same time. Y2 is not counted at all.
 
Back
Top