Advanced Filters with Unions

J

John

I am having a challenge with the following code. It has an issue with the
advanced filter. Does anyone know if it is possible to apply an advanced
filter on a union of ranges?

Sub TestIt()
Dim r1 As Range, r2 As Range, myMultiAreaRange As Range
Worksheets("sheet1").Activate
Set r1 = Range("A4:A9")
Set r2 = Range("D4:E9")
Set myMultiAreaRange = Union(r1, r2)
'myMultiAreaRange.Select

myMultiAreaRange.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=ThisWorkbook.Sheets("Sheet1").Range("R_Criteria"), _
CopyToRange:=ThisWorkbook.Sheets("Sheet1").Range("H4:J4"), Unique:=False


End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top