I have a sub that will filter on criteria and then delete those rows, it's a sub so I can pass different filter criteria to it each time. I've decided to trim it down by passing an array instead of doing mnultiple separate filters on each row... but it fails.
I'm using excel 2007.
I've simplified the piece that fails to the below and thecode below that which works.
Sub autofilter_with_array_fails()
RemoveValue = "Array(""Value1"", ""Value2"", ""Value3"", ""Value4"", ""Value5"", ""Value6"")"
ActiveSheet.Range("A1").AutoFilter Field:=3, Criteria1:=RemoveValue, Operator:=xlFilterValues
End Sub
Sub autofilter_with_array_works()
ActiveSheet.Range("A1").AutoFilter Field:=3, Criteria1:=Array("Value1", "Value2", "Value3", "Value4", "Value5", "Value6"), Operator:=xlFilterValues
End Sub
To me they seem to be doing exactly the same thing. What am I doing wrong?
I'm using excel 2007.
I've simplified the piece that fails to the below and thecode below that which works.
Sub autofilter_with_array_fails()
RemoveValue = "Array(""Value1"", ""Value2"", ""Value3"", ""Value4"", ""Value5"", ""Value6"")"
ActiveSheet.Range("A1").AutoFilter Field:=3, Criteria1:=RemoveValue, Operator:=xlFilterValues
End Sub
Sub autofilter_with_array_works()
ActiveSheet.Range("A1").AutoFilter Field:=3, Criteria1:=Array("Value1", "Value2", "Value3", "Value4", "Value5", "Value6"), Operator:=xlFilterValues
End Sub
To me they seem to be doing exactly the same thing. What am I doing wrong?