Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
MPM MPM is offline
external usenet poster
 
Posts: 1
Default How to get a macro to run that uses a protected sheet

I would like to create some simple macros (e.g. selecting criteria within an
autofilter and then printing the result) but I would also like to protect the
sheet that contains the Autofiltered data.

When I turn protection on the macro fails.

Is there any way to run macros AND protect sheets?

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default How to get a macro to run that uses a protected sheet

In code you need to unprotect then execute your code and then reprotect.
There is no way around it...
--
HTH...

Jim Thomlinson


"MPM" wrote:

I would like to create some simple macros (e.g. selecting criteria within an
autofilter and then printing the result) but I would also like to protect the
sheet that contains the Autofiltered data.

When I turn protection on the macro fails.

Is there any way to run macros AND protect sheets?

Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default How to get a macro to run that uses a protected sheet

Have then macro turn protection off and then when done turn it back on:

Sub MyMacro()

Sheets("Sheet1").Unprotect
' Run the rest of your code here
Sheets("Sheet1").Protect

End Sub
--
- K Dales


"MPM" wrote:

I would like to create some simple macros (e.g. selecting criteria within an
autofilter and then printing the result) but I would also like to protect the
sheet that contains the Autofiltered data.

When I turn protection on the macro fails.

Is there any way to run macros AND protect sheets?

Thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How to get a macro to run that uses a protected sheet

Activesheet.Protect UserInterfaceOnly:=True
ActiveSheet.EnableAutofilter = True

the autofilter must already exists, but you can change the criteria.

In xl2002 and later, I believe you have to supply the password (if there is
one) when you do the Protect command.

--
Regards,
Tom Ogilvy


"MPM" wrote in message
...
I would like to create some simple macros (e.g. selecting criteria within

an
autofilter and then printing the result) but I would also like to protect

the
sheet that contains the Autofiltered data.

When I turn protection on the macro fails.

Is there any way to run macros AND protect sheets?

Thanks



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro & Protected sheet Lise Excel Discussion (Misc queries) 2 April 11th 10 10:36 PM
use macro button to run macro in protected sheet earl Excel Discussion (Misc queries) 3 February 26th 06 10:21 PM
use macro on a protected sheet das.s.k Excel Programming 2 March 14th 05 07:57 PM
excel - macro code to open a protected sheet, enter passowrd, and then protect sheet arunjoshi[_5_] Excel Programming 1 May 2nd 04 03:50 PM
Using a Macro with the sheet protected. Jason Watts Excel Programming 1 January 6th 04 09:31 PM


All times are GMT +1. The time now is 01:42 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"