I have a sheet called database where I filter the data in using
advanced filter.
I have a sheet called criteria that has the criteria range and the
extraction range.
1. I used codes to find my used range in the database = filterRange
2. I define my criteria range =CriteriaRange
3. I define my extraction range = ExtractionRange
4 I apply the Advanced filter codes to the ranges.
Please could look over the codes, it is not working.
Sub DailyCowList()
' Show the database used range
Worksheets("database").Activate
DmyLastCell = LastCell(Worksheets("Database")).Address
DmyRange = "a4:" & DmyLastCell
Application.ScreenUpdating = True
Range(DmyRange).Select
'to verify the range
MsgBox DmyRange
MsgBox DmyLastCell
LimitRange = "A25:" & DmyLastCell
Set FilterRange = Worksheets("Database").Range(DmyRange)
Worksheets("Criteria").Activate
With Worksheets("Criteria")
Set CriteriaRange = .Range("A2:U22")
Set ExtractionRange = .Range(LimitRange)
End With
' Advanced filter
FilterRange.AdvancedFilter _
Action:=xlFilterCopy, _
CriteriaRange:=CriteriaRange, _
CopyToRange:=ExtractionRange