PC Review


Reply
Thread Tools Rate Thread

AutoFilter can't work after the worksheet is being protected!!!

 
 
=?Utf-8?B?SmFj?=
Guest
Posts: n/a
 
      26th Jun 2007
Hi,

I've recorded a macro which would help me to filter for desired records in a
data list using MS Excel 2003. After that, I assigned the macro to a command
button. But I wish to locked the location of the button on the worksheet, top
(100), left (50). So I used Protect Sheet option to protect the sheet with
Use AutoFilter option being selected. Unfortunately, once I run the macro
after the sheet is protected; a debug will be generated, "Run-time error
1004"!!!

What would be the cause for the debug???
Anyone could help on this????

Thanking in advance.


 
Reply With Quote
 
 
 
 
=?Utf-8?B?c3RldmVfZG9j?=
Guest
Posts: n/a
 
      26th Jun 2007
Cause of the error is your worksheet protection afaik
especialy if you are trying to paste some data into protected sheet

Easy solution - programme your macro to unprotect the sheet
Perform rest of code
Then protect the worksheet again

HTH

"Jac" wrote:

> Hi,
>
> I've recorded a macro which would help me to filter for desired records in a
> data list using MS Excel 2003. After that, I assigned the macro to a command
> button. But I wish to locked the location of the button on the worksheet, top
> (100), left (50). So I used Protect Sheet option to protect the sheet with
> Use AutoFilter option being selected. Unfortunately, once I run the macro
> after the sheet is protected; a debug will be generated, "Run-time error
> 1004"!!!
>
> What would be the cause for the debug???
> Anyone could help on this????
>
> Thanking in advance.
>
>

 
Reply With Quote
 
Bob Umlas
Guest
Posts: n/a
 
      26th Jun 2007
Have the code first unprotect the sheet, do its thing, then reprotect the
sheet.

"Jac" <(E-Mail Removed)> wrote in message
news:A680F83B-06B9-4882-BF2F-(E-Mail Removed)...
> Hi,
>
> I've recorded a macro which would help me to filter for desired records in
> a
> data list using MS Excel 2003. After that, I assigned the macro to a
> command
> button. But I wish to locked the location of the button on the worksheet,
> top
> (100), left (50). So I used Protect Sheet option to protect the sheet with
> Use AutoFilter option being selected. Unfortunately, once I run the macro
> after the sheet is protected; a debug will be generated, "Run-time error
> 1004"!!!
>
> What would be the cause for the debug???
> Anyone could help on this????
>
> Thanking in advance.
>
>



 
Reply With Quote
 
=?Utf-8?B?SmFj?=
Guest
Posts: n/a
 
      26th Jun 2007
Hi Bob,

Thanks for your help...... ; )
The problem solved now!!

But what is that Use AutoFilter option actually use for in protection???
Why even we selected the option the AutoFilter won't work also???




"Bob Umlas" wrote:

> Have the code first unprotect the sheet, do its thing, then reprotect the
> sheet.
>
> "Jac" <(E-Mail Removed)> wrote in message
> news:A680F83B-06B9-4882-BF2F-(E-Mail Removed)...
> > Hi,
> >
> > I've recorded a macro which would help me to filter for desired records in
> > a
> > data list using MS Excel 2003. After that, I assigned the macro to a
> > command
> > button. But I wish to locked the location of the button on the worksheet,
> > top
> > (100), left (50). So I used Protect Sheet option to protect the sheet with
> > Use AutoFilter option being selected. Unfortunately, once I run the macro
> > after the sheet is protected; a debug will be generated, "Run-time error
> > 1004"!!!
> >
> > What would be the cause for the debug???
> > Anyone could help on this????
> >
> > Thanking in advance.
> >
> >

>
>
>

 
Reply With Quote
 
=?Utf-8?B?SmFj?=
Guest
Posts: n/a
 
      26th Jun 2007
Hi Bob,

Thanks for you help........ : )
Now my problem has solved!!

Anyway, what actually that Use AutoFilter option is use for in protection??
Why even we selected the option but still can't use the AutoFilter during
the protection???



"Bob Umlas" wrote:

> Have the code first unprotect the sheet, do its thing, then reprotect the
> sheet.
>
> "Jac" <(E-Mail Removed)> wrote in message
> news:A680F83B-06B9-4882-BF2F-(E-Mail Removed)...
> > Hi,
> >
> > I've recorded a macro which would help me to filter for desired records in
> > a
> > data list using MS Excel 2003. After that, I assigned the macro to a
> > command
> > button. But I wish to locked the location of the button on the worksheet,
> > top
> > (100), left (50). So I used Protect Sheet option to protect the sheet with
> > Use AutoFilter option being selected. Unfortunately, once I run the macro
> > after the sheet is protected; a debug will be generated, "Run-time error
> > 1004"!!!
> >
> > What would be the cause for the debug???
> > Anyone could help on this????
> >
> > Thanking in advance.
> >
> >

>
>
>

 
Reply With Quote
 
=?Utf-8?B?SmFj?=
Guest
Posts: n/a
 
      26th Jun 2007
Hi Steve,

Thanks for your help.......... : )
my problem has solved now!!!



"steve_doc" wrote:

> Cause of the error is your worksheet protection afaik
> especialy if you are trying to paste some data into protected sheet
>
> Easy solution - programme your macro to unprotect the sheet
> Perform rest of code
> Then protect the worksheet again
>
> HTH
>
> "Jac" wrote:
>
> > Hi,
> >
> > I've recorded a macro which would help me to filter for desired records in a
> > data list using MS Excel 2003. After that, I assigned the macro to a command
> > button. But I wish to locked the location of the button on the worksheet, top
> > (100), left (50). So I used Protect Sheet option to protect the sheet with
> > Use AutoFilter option being selected. Unfortunately, once I run the macro
> > after the sheet is protected; a debug will be generated, "Run-time error
> > 1004"!!!
> >
> > What would be the cause for the debug???
> > Anyone could help on this????
> >
> > Thanking in advance.
> >
> >

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      26th Jun 2007
Toggling that setting to allow autofiltering will allow the user to autofilter
an existing filter. But not your code.

You could unprotect the worksheet, do the work, reprotect the worksheet (like
others have said).

Or you could protect the worksheet and tell excel that you want to be able to
let your code do things, too, by using a special setting
(UserInterfaceOnly:=true, below):

If you already have the outline/subtotals/autofilter applied, you can protect
the worksheet in code (auto_open/workbook_open??).

Option Explicit
Sub auto_open()
With Worksheets("sheet1")
.Protect Password:="hi", userinterfaceonly:=True
'.EnableOutlining = True
.EnableAutoFilter = True
End With
End Sub

It needs to be reset each time you open the workbook. (Earlier versions of
excel don't remember it after closing the workbook. IIRC, xl2002+ will remember
the allow autofilter setting under tools|Protection|protect sheet.)

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Jac wrote:
>
> Hi,
>
> I've recorded a macro which would help me to filter for desired records in a
> data list using MS Excel 2003. After that, I assigned the macro to a command
> button. But I wish to locked the location of the button on the worksheet, top
> (100), left (50). So I used Protect Sheet option to protect the sheet with
> Use AutoFilter option being selected. Unfortunately, once I run the macro
> after the sheet is protected; a debug will be generated, "Run-time error
> 1004"!!!
>
> What would be the cause for the debug???
> Anyone could help on this????
>
> Thanking in advance.


--

Dave Peterson
 
Reply With Quote
 
=?Utf-8?B?SmFj?=
Guest
Posts: n/a
 
      26th Jun 2007
Hi Dave,

Thanks for your feedback!!!


"Dave Peterson" wrote:

> Toggling that setting to allow autofiltering will allow the user to autofilter
> an existing filter. But not your code.
>
> You could unprotect the worksheet, do the work, reprotect the worksheet (like
> others have said).
>
> Or you could protect the worksheet and tell excel that you want to be able to
> let your code do things, too, by using a special setting
> (UserInterfaceOnly:=true, below):
>
> If you already have the outline/subtotals/autofilter applied, you can protect
> the worksheet in code (auto_open/workbook_open??).
>
> Option Explicit
> Sub auto_open()
> With Worksheets("sheet1")
> .Protect Password:="hi", userinterfaceonly:=True
> '.EnableOutlining = True
> .EnableAutoFilter = True
> End With
> End Sub
>
> It needs to be reset each time you open the workbook. (Earlier versions of
> excel don't remember it after closing the workbook. IIRC, xl2002+ will remember
> the allow autofilter setting under tools|Protection|protect sheet.)
>
> If you're new to macros, you may want to read David McRitchie's intro at:
> http://www.mvps.org/dmcritchie/excel/getstarted.htm
>
> Jac wrote:
> >
> > Hi,
> >
> > I've recorded a macro which would help me to filter for desired records in a
> > data list using MS Excel 2003. After that, I assigned the macro to a command
> > button. But I wish to locked the location of the button on the worksheet, top
> > (100), left (50). So I used Protect Sheet option to protect the sheet with
> > Use AutoFilter option being selected. Unfortunately, once I run the macro
> > after the sheet is protected; a debug will be generated, "Run-time error
> > 1004"!!!
> >
> > What would be the cause for the debug???
> > Anyone could help on this????
> >
> > Thanking in advance.

>
> --
>
> Dave Peterson
>

 
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
AUTOFILTER IN A PROTECTED WORKSHEET William Microsoft Excel Misc 1 22nd Aug 2008 10:27 PM
AutoFilter on a protected worksheet ADK Microsoft Excel Programming 0 13th Jul 2007 07:29 PM
autofilter in protected worksheet? Kate Microsoft Excel Worksheet Functions 4 20th Jul 2004 11:45 AM
Autofilter in protected worksheet Gustavo Microsoft Excel Misc 2 28th May 2004 12:54 AM
autofilter in protected worksheet Ki Microsoft Excel Misc 3 13th Oct 2003 12:41 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:15 AM.