PC Review


Reply
Thread Tools Rate Thread

Cannot Reset a Protected List

 
 
=?Utf-8?B?Qm9uemFp?=
Guest
Posts: n/a
 
      6th Jul 2007
Using Excel 2003. I created a Reset Macro to reset all AutoFilters to “All”
in a list. The macro looks like:

Sub Reset()
Range("A6").Select
Selection.AutoFilter Field:=1
Range("B6").Select
Selection.AutoFilter Field:=2
End Sub

The above works fine until I password-protect the worksheet, and then I get
a “Run Time Error 1004 , cannot use this command on a protected t sheet”.
Even though I allow users to Sort & Use Autofilter. Any suggestions? Thanks
in advance for your help.

--
Merci!
Bonzai
 
Reply With Quote
 
 
 
 
Gary Keramidas
Guest
Posts: n/a
 
      6th Jul 2007
try something like this

Sub Reset()
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
With ws
.Unprotect Password:="password"
With .Range("A6")
.AutoFilter Field:=1
.AutoFilter Field:=2
End With
.Protect Password:="password"
End With

End Sub

--


Gary


"Bonzai" <(E-Mail Removed)> wrote in message
news:A6230B4C-CC8B-4F3A-B9D4-(E-Mail Removed)...
> Using Excel 2003. I created a Reset Macro to reset all AutoFilters to "All"
> in a list. The macro looks like:
>
> Sub Reset()
> Range("A6").Select
> Selection.AutoFilter Field:=1
> Range("B6").Select
> Selection.AutoFilter Field:=2
> End Sub
>
> The above works fine until I password-protect the worksheet, and then I get
> a "Run Time Error 1004 , cannot use this command on a protected t sheet".
> Even though I allow users to Sort & Use Autofilter. Any suggestions? Thanks
> in advance for your help.
>
> --
> Merci!
> Bonzai



 
Reply With Quote
 
=?Utf-8?B?Qm9uemFp?=
Guest
Posts: n/a
 
      6th Jul 2007
Thank you very much Gary, it worked!
--
Merci!
Bonzai


"Gary Keramidas" wrote:

> try something like this
>
> Sub Reset()
> Dim ws As Worksheet
> Set ws = Worksheets("Sheet1")
> With ws
> .Unprotect Password:="password"
> With .Range("A6")
> .AutoFilter Field:=1
> .AutoFilter Field:=2
> End With
> .Protect Password:="password"
> End With
>
> End Sub
>
> --
>
>
> Gary
>
>
> "Bonzai" <(E-Mail Removed)> wrote in message
> news:A6230B4C-CC8B-4F3A-B9D4-(E-Mail Removed)...
> > Using Excel 2003. I created a Reset Macro to reset all AutoFilters to "All"
> > in a list. The macro looks like:
> >
> > Sub Reset()
> > Range("A6").Select
> > Selection.AutoFilter Field:=1
> > Range("B6").Select
> > Selection.AutoFilter Field:=2
> > End Sub
> >
> > The above works fine until I password-protect the worksheet, and then I get
> > a "Run Time Error 1004 , cannot use this command on a protected t sheet".
> > Even though I allow users to Sort & Use Autofilter. Any suggestions? Thanks
> > in advance for your help.
> >
> > --
> > Merci!
> > Bonzai

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reset radio buttons w/ protected worksheet dgold82 Microsoft Excel Programming 2 24th Apr 2009 06:01 PM
Use VBA to reset data validation (=list) value to first value in that list (list is a named range) ker_01 Microsoft Excel Programming 7 27th Oct 2008 03:13 PM
Reset user upon exiting protected database Jeffrey Ah-Chong Microsoft Access 3 15th Aug 2005 08:49 AM
Ranges in protected worksheet will not reset =?Utf-8?B?V2Fpa2VsZSBMaW4=?= Microsoft Excel Misc 4 14th Jun 2004 07:13 PM
Reset the Show Folder Contents option on protected directories Joe Brazell Windows XP Customization 3 2nd Apr 2004 11:11 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:30 AM.