Excel 2002 Protect Sheet & Use AutoFilter Option

turbotoan

Board Regular
Joined
Feb 25, 2002
Messages
62
Has anyone come up with a way to code up this functionality to work in Excel 97?
Essentially, I need to protect a sheet, but allow AutoFilter to be used for viewing purposes. In Excel 97 this is not permitted (even if the columns you want to AutoFilter on are NOT locked...).

See this site for what it is supposed to do in Excel 2002 - "http://support.microsoft.com/default.aspx?scid=kb;EN-US;q289269"

I'll appreciate the help...
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Hi Turbotoan

The only way around this I have found is to provide 2 macro buttons on a part of the sheet which will not get hidden when lines are filtered.
Name on Button 1 = "Filter by entry in D1"
Name on Button 2 = "Show all Data"
Macro1 Code:
On Error Resume Next
ActiveSheet.Unprotect("yourpassword")
Selection.AutoFilter Field:=4, Criteria1:=Range("D1").Value, Operator:=xlAnd
ActiveSheet.Protect("yourpassword")
End Sub

Note: Here I am using Field 4 and picking up the criterial value from cell D1 (change to suit your circumstances)

Macro2 Code:
On Error Resume Next
ActiveSheet.Unprotect("yourpassword")
ActiveSheet.ShowAllData
ActiveSheet.Protect("yourpassword")
End Sub

You will have to provide some instructions to get your user to type into D1 (or your chosen cell) the criteria to filter by. Or perhaps you could do it with an input box?

Good luck
Derek
 
Upvote 0
Try this, I got this from Mr Excel (can't remember who) and it worked for me.

Sub protect1()
ActiveSheet.EnableAutoFilter = True
ActiveSheet.Protect Contents:=True, userInterfaceOnly:=True

End Sub

Lisa
 
Upvote 0

Forum statistics

Threads
1,214,516
Messages
6,119,978
Members
448,934
Latest member
audette89

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