DHGranstrand
Technical User
I am trying to autofilter a report that has a variable number of lines month to month to display only certain employees data.
I have a named range ("ShowNames") that I want Autofilter to use as the filter values.
The report is emailed to me monthly so I run the macro from a second Excel workbook which also has the named range.
The macro runs fine except that it only filters on the first value in the named range.
Here is the code:
Sub AutofilterNames()
Dim a1 As Variant
a1 = Range("ShowNames").Value
' Select Report To Filter
Windows("MasterReport.xls").Activate
' Position Curser For Range Selection
Range("A1").Select
' Autoselect Range of Data & Turn Filter On
ActiveSheet.Range(Selection.End(xlToRight), Selection.End(xlDown)).Autofilter Field:=1, _
Criteria1:=a1, Operator:=xlFilterValues
End Sub
Thanks for the help!!
I have a named range ("ShowNames") that I want Autofilter to use as the filter values.
The report is emailed to me monthly so I run the macro from a second Excel workbook which also has the named range.
The macro runs fine except that it only filters on the first value in the named range.
Here is the code:
Sub AutofilterNames()
Dim a1 As Variant
a1 = Range("ShowNames").Value
' Select Report To Filter
Windows("MasterReport.xls").Activate
' Position Curser For Range Selection
Range("A1").Select
' Autoselect Range of Data & Turn Filter On
ActiveSheet.Range(Selection.End(xlToRight), Selection.End(xlDown)).Autofilter Field:=1, _
Criteria1:=a1, Operator:=xlFilterValues
End Sub
Thanks for the help!!