View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default selecting an AutoFilter value in code

Try something like


Dim WS As Worksheet
Set WS = ActiveSheet
WS.UsedRange.AutoFilter field:=1, Criteria1:="Texas"

Change the 1 to the column number of the column you are filtering
on.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Paul Ponzelli" wrote in
message ...
Is there a way to set the value of an AutoFilter drop box in
code?

Assume you've already run the following code to show all
records:

If Sheets("Address").FilterMode Then
Sheets("Address").ShowAllData
End If

Is there a line of code you can run to filter the records by a
particular value in one of the autofilter drop boxes? Let's
say, for example, that one of the values in the AutoFilter drop
box in cell C1 is "Texas." Is there a way to set that value in
the AutoFilter to "Texas"?

Thanks in advance,

Paul