Autofilter Problem

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
2,341
Office Version
  1. 365
Platform
  1. Windows
I have this code that work if the sheet has no Filters on - then it puts the filters "on" but if there are filters its turning them off

I need them to always be on. Thats what I thought Selection.AutoFilter did. How do I check if is not on - then turn on the filters, but if they are already on then leave them on? Thanks!


Code:
Sub GoToStep1()

Sheets("Step 1").Visible = True
Sheets("Step 2").Visible = xlSheetVeryHidden
Sheets("Step 1").Activate
Range("B10").Select
 Selection.AutoFilter

    Sheets("Step 3").Visible = xlSheetVeryHidden
    Sheets("Step 4").Visible = xlSheetVeryHidden
    Sheets("Step 5").Visible = xlSheetVeryHidden
    Sheets("Step 6").Visible = xlSheetVeryHidden
    Sheets("Step 7").Visible = xlSheetVeryHidden
    Sheets("SSJ").Visible = xlSheetVeryHidden
    Sheets("Other Tables").Visible = xlSheetVeryHidden
    
    Sheets("DM Parts").Visible = xlSheetVeryHidden
    Sheets("DM Cost Sources").Visible = xlSheetVeryHidden
    Sheets("DM Cost Source Details").Visible = xlSheetVeryHidden
    Sheets("DM Vendors").Visible = xlSheetVeryHidden
    
    Sheets("Parts").Visible = xlSheetVeryHidden
    Sheets("Cost Sources").Visible = xlSheetVeryHidden
    Sheets("Cost Source Details").Visible = xlSheetVeryHidden
    Sheets("Vendors").Visible = xlSheetVeryHidden

End Sub
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
How about
VBA Code:
If Not ActiveSheet.AutoFilterMode Then Range("B1").AutoFilter
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,807
Messages
6,121,679
Members
449,047
Latest member
notmrdurden

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top