Reputation: 1886
Trying to auto-refresh an advanced filter in Sheet2 using data and criteria from Sheet1. Seems straight forward enough but the following code results in a 1004 error with the range object no matter what I try. What am I missing?
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Range("Sheet1!A1:C4").AdvancedFilter Action:=xIFilterCopy, _
CriteriaRange:=Range("Sheet1!E1:E2"), _
CopyToRange:=Range("Sheet2!A1:B4"), _
Unique:=False
End Sub
Thanks.
Upvotes: 0
Views: 75
Reputation: 2169
There is an implicit Me.
in front of the Range
call when it's called within a worksheet module. So it's only looking in sheet2 for a range called "Sheet1!E1:E2". It would work in a stand alone module (so you could create a procedure call) or if you use @Joshua Ross suggestion in the comments.
Upvotes: 1