View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
RCL RCL is offline
external usenet poster
 
Posts: 10
Default Range inside Array not working

With macro recorder I generated this code

Sub Macro6()
ActiveSheet.Range("$A$1:$I$5004").AutoFilter Field:=1, _
Criteria1:=Array("1", "2"), Operator:=xlFilterValues
End Sub

My objetive is to replace the array values with my named range, so I
do this:

In cell A1 I write value 1
In cell A2 I write value 2
I create a named range called "CR", wich refers to range("A1:A2")

Then I modify my macro to this, to include the named range inside the
array:

Sub Macro6()
ActiveSheet.Range("$A$1:$I$5004").AutoFilter Field:=1, _
Criteria1:=Array(Range("CR")), Operator:=xlFilterValues
End Sub

The problem is that it doesn´t work...What I am doing wrong?