Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Filter Macro
"Dennis@Merlin" wrote in message
... :I have a workbook with multiple worksheets and each WS has a different number : of rows. I'm trying to write a single macro that I can use with each WS : indicidually to filter the data. Here's my code; but I get a Run-time error : '1004' ; Method Range of object '_Global' failed on the line before End Sub. : : Sub FilterData() : Dim MyRange As Range : Range("E10").Activate : Set MyRange = Range("E10", Cells(Rows.Count, 5).End(xlUp)) : Range("MyRange").AdvancedFilter Action:=xlFilterInPlace, : CriteriaRange:=Range("E1:E2"), Unique:=False : End Sub I don't think you can Range("MyRange") since it is already a range. Also, I deleted the activate since typically this is not needed but if you did want it, then put it back. Sub FilterData() Dim MyRange As Range Set MyRange = Range("E10", Cells(Rows.Count, 5).End(xlUp)) MyRange.AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=Range("E1:E2"), Unique:=False End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro Filter | Excel Worksheet Functions | |||
how can this filter be done in a macro? | Excel Discussion (Misc queries) | |||
Need macro to filter, create tab on filter and copy/paste | Excel Programming | |||
Need macro to filter, create tab on filter and copy/paste | Excel Programming | |||
Filter in macro | Excel Programming |