Apply more than one filter in macro/vb code

  • Thread starter Thread starter Stepnen
  • Start date Start date
S

Stepnen

**Re-Posted**
I need code that enables a user to 'turn on' one or more
filters in a spreadsheet. Currently have a btn that has
statement if ActiveSheet.FilterMode Then
Selection.AutoFilter Field:=27 else
Selection.AutoFilter Field:=27, Criteria1:="="
(thus btn turns filter on and off)
Also have simular statement in other btns, but need more
that one btn to be able to work at same time.

Many thanks for everyones help in this.
**Re-Posted**

Yes. If I manually apply the change it works... After the
first filter is applied, there is still records (rows)
that could be filtered out by the second.. but it does not
work. Also whwn a filter is aplied the drop down filter
goes blue, but of cause mine does not work.. please help.
 
So do you want something like a toggle?

Button1:
If Worksheets("Sheet1").AutoFilter.Filters(27).On Then
Selection.AutoFilter Field:=27
Else
Selection.AutoFilter Field:=27, Criteria1:="="
End If

Button2:
If Worksheets("Sheet1").AutoFilter.Filters(26).On Then
Selection.AutoFilter Field:=26
Else
Selection.AutoFilter Field:=26, Criteria1:="0"
End If

**Re-Posted**
I need code that enables a user to 'turn on' one or more
filters in a spreadsheet. Currently have a btn that has
statement if ActiveSheet.FilterMode Then
Selection.AutoFilter Field:=27 else
Selection.AutoFilter Field:=27, Criteria1:="="
(thus btn turns filter on and off)
Also have simular statement in other btns, but need more
that one btn to be able to work at same time.

Many thanks for everyones help in this.
**Re-Posted**

Yes. If I manually apply the change it works... After the
first filter is applied, there is still records (rows)
that could be filtered out by the second.. but it does not
work. Also whwn a filter is aplied the drop down filter
goes blue, but of cause mine does not work.. please help.
 
Back
Top