The named range doesn't change when a filter is applied to the range.
You could add a bit more code, and create a list of names after the
filter is applied, then rename the revised range. For example, in the
sample workbook:
'==============
'create unique list of products
wsO.Range("Database").AdvancedFilter _
Action:=xlFilterCopy, CriteriaRange:=wsO.Range("G1:H2"), _
CopyToRange:=wsDL.Range("G1"), Unique:=True
wsDL.Range("G1").CurrentRegion.Sort _
Key1:=wsDL.Range("G2"), Order1:=xlAscending, header:=xlYes
ThisWorkbook.Names.Add Name:="Products", _
RefersTo:=wsDL.Range("G1").CurrentRegion
'==============
When you remove the filter, add code to create the full list of names,
and rename it.
'===================
''create unique list of products
wsO.Range("Database").AdvancedFilter _
Action:=xlFilterCopy, CriteriaRange:="", _
CopyToRange:=wsDL.Range("G1"), Unique:=True
wsDL.Range("G1").CurrentRegion.Sort _
Key1:=wsDL.Range("G2"), Order1:=xlAscending, header:=xlYes
ThisWorkbook.Names.Add Name:="Products", _
RefersTo:=wsDL.Range("G1").CurrentRegion
'====================
Arnold wrote:
> Greetings All,
>
> I set up a filter similar to Debra Dalgleish's Filter for Date Range,
> using a numeric range instead. This works fine.
>
> There is student data on a sheet named "Students," and filter criteria
> (grade levels 6 through 12) are on a sheet named "Schedules". On the
> "Schedules sheet are separate ranges for different class periods--each
> cell contains data validation with its source set =AbbNames, which is a
> column on the "Students" sheet. This allows the user to select student
> names instead of typing them.
>
> With the filter on, however, the listboxes still show the entire list
> of students. For ex, if grades 11 and 12 are selected, all students in
> the school are given in the drop down list. Why? Is there a way to
> fix this and limit the contents of the list box to the filtered names?
>
> Thanks much,
> Arnold
>
--
Debra Dalgleish
Contextures
http://www.contextures.com/tiptech.html