I have been trying to implement Advance Filtering using VBA with dynamic Criteria.
The Criteria Range will change based on the Filters on a Table from where I am picking the Criteria (located on a different sheet).
For example, in the below picture I need the criteria to be G5. If I change the filters on any of the columns, then the Criteria Range will be some other cells from G Column itself. The Column will always be G but the range of cells will differ.
Hence, I am first using a macro to select ONLY the visible cells after filtering, "Go To Special->Visible Cells" (Selection.SpecialCells(xlCellTypeVisible))
I have written the following piece of code, but it is giving the error "Criteria range not valid" for the Advance Filtering code.
Dim Criteria As Range
Sheets("<DM>Product").Select
Columns("G:G").Select
Set Criteria = Selection.SpecialCells(xlCellTypeVisible)
Range("Table2[#All]").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange _
:=Criteria, Unique:=True
I am a newbie in VBA and any help will be appreciated.