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.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.