WorkBook Open to show all Autofiltered rows

Dave T

Board Regular
Joined
Jun 21, 2005
Messages
93
Hello All,

I use the following macro in a workbook and would like to modify it so that each time the workbook is opened each of the worksheets has the AutoFilter criteria removed.
I would like the Filter criteria to be reset to 'All' but still retain the AutoFilter dropdown arrows.

Code:
Private Sub Workbook_Open()
    Dim Sh As Worksheet
    Application.ScreenUpdating = False
    For Each Sh In ThisWorkbook.Worksheets
    Sh.Select
    Sh.Protect userinterfaceonly:=True
    Sh.EnableSelection = xlUnlockedCells
    Sh.EnableAutoFilter = True
Next
    Sheets(1).Select
    Application.ScreenUpdating = True
End Sub
[Code]

Thanks in advance

Regards,
Dave T
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Hello sandeep.warrier,

Thanks for the reply

I tried to insert what you havew suggested but when the workbook opens I get an error message that says:

Run-time error '438':
Object doesn't support this property or method

I am using Excel 2003 so I don't know iif this has anything to do with the problem.

Regards,
Dave T
 
Upvote 0
Can you help me with this problem?
Principle $140,000
Rate 7.25%
Years 15
Payement 1,278.01

The answer to the PV function is 134,638.06
 
Upvote 0
I have tested this code and it works on my PC. I also use Excel 2003 so you should not have any problems..


Code:
Sub test()
 
    Dim ws As Worksheet

    For Each ws In ThisWorkbook.Worksheets
    
        ws.Select
        ws.ShowAllData
    
    Next ws
 
End Sub
 
Upvote 0
Hello sandeep.warrier,

Thanks again for the reply

I tried what you suggested and even renamed all instances of Sh.Select, etc. to ws.Select and I now get an error message that now says:

Run-time error '1004':
Method 'ShaowAllData' of object '_Worksheet' failed

Could you please add/insert your suggested code to my original macro so I can see where it should be included and help me understand why i does not work for me.

Thanks again.

Dave T
 
Upvote 0
I tested this too and it worked fine.

Please note that you need to paste this in the module for ThisWorkbook and not in any other module.

Code:
Private Sub Workbook_Open()
    Dim Sh As Worksheet
    
    Application.ScreenUpdating = False
    
    For Each Sh In ThisWorkbook.Worksheets
        
        Sh.Select
        Sh.ShowAllData
        Sh.EnableSelection = xlUnlockedCells
        Sh.EnableAutoFilter = True
        Sh.Protect userinterfaceonly:=True
        
    Next
    
    Sheets(1).Select
    
    Application.ScreenUpdating = True
End Sub

Regards,
Sandeep.
 
Upvote 0
ShowAllData will error if all data is already showing.

Use

On error resume next
sh.showalldata
err.clear
 
Upvote 0

Forum statistics

Threads
1,207,442
Messages
6,078,581
Members
446,349
Latest member
Malroos7912

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