Workbook alternating between showing autofilter and then not showing it each time workbook is opened... how to always show it?

kbishop94

Active Member
Joined
Dec 5, 2016
Messages
458
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
I save the workbook, then close it.
Open it up, and autofilter is showing:
AutoFilter-SHOWING-11.jpg

then, save & close it again...
and then open it back up,
AutoFilter-NOT SHOWING-11.jpg
and now its no longer showing...(?):

So I save it once more, and then the next time I open it, it will be back to showing once again(!) (and again, save it one more time and of course next time I open it it goes back to not showing....) whats causing this crazy loop?

VBA Code:
Private Sub Workbook_Open()
'
    If ActiveSheet.AutoFilterMode Then
        ActiveSheet.Range("C2:S2").AutoFilter
    Else
        ActiveSheet.Range("C2:S2").AutoFilter
    End If
'


I've tried putting the above code in different places (at the very top of the workbook open event and also at the very bottom) as well as trying different variations of the code, but it still behaves exactly the same; it will show once, then next time, it wont. wtheck?
Thanks
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
whats causing this crazy loop?
If Autofilter is on and you ask it to autofilter, the filter arrows will go off and vica versa

That is why they keep alternating...

You can try that by using keyboard shortcut Ctrl+Shift+F (in mac) there must be similar or same in windows, to understand the scenario
 
Upvote 0
How about
VBA Code:
    If ActiveSheet.AutoFilterMode Then
    Else
        ActiveSheet.Range("C2:S2").AutoFilter
    End If
 
Upvote 0
Solution
If the autofilter is on then you were turning it off.
 
Upvote 0
If Autofilter is on and you ask it to autofilter, the filter arrows will go off and vica versa

That is why they keep alternating...

You can try that by using keyboard shortcut Ctrl+Shift+F (in mac) there must be similar or same in windows, to understand the scenario
yes, i understand that (believe it or not lol) But the code is supposed to (so I thought.. and it does work in another workbook... :unsure: ) keep it on regardless if its showing one time or not showing... Oh well. Its working now! Thank you for the reply.
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,091
Messages
6,123,062
Members
449,089
Latest member
ikke

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