Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Felix
 
Posts: n/a
Default How can you create a macro on a protected sheet?

I have a shared worksheet that I have password protected so no one can change
formulas in the cells. I would like to set up macros to provide me with a
certain view for printing and research. Everytime I set up the macro and
protect the sheet it says that I can not use the macro.

Is there anyway around this or will I have to unprotect the sheet everytime
I want to use the macro? Any ideas or suggestions would be greatly
appreciated. Thank you.
  #2   Report Post  
Posted to microsoft.public.excel.misc
patrickcairns
 
Posts: n/a
Default How can you create a macro on a protected sheet?


You could have the macro unprotect the sheet, run what it is suppose to
do and then have it re-protect it.


--
patrickcairns
------------------------------------------------------------------------
patrickcairns's Profile: http://www.excelforum.com/member.php...o&userid=31790
View this thread: http://www.excelforum.com/showthread...hreadid=515557

  #3   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default How can you create a macro on a protected sheet?

If you set up the protection and the macro, then you know the password?

Option Explicit
sub testme()
dim myPWD as string
myPwd = "hi there"
activesheet.unprotect password:=myPWD
'do your stuff
activesheet.protect password:=mypwd
end sub

======
Depending on what your code does, you could even protect it in code (each time
the workbook opens) and tell excel that you want to allow your macro to do
things that the humans can't.

Option Explicit
Sub auto_open()
With Worksheets("Sheet 99")
.Protect Password:="hi there", userinterfaceonly:=True
End With
End Sub

It needs to be reset each time you open the workbook. (excel doesn't remember
it after closing the workbook.)

But there are a few things that can't be done by your macro--you'll want to test
it to see if it works with the stuff you do.

Felix wrote:

I have a shared worksheet that I have password protected so no one can change
formulas in the cells. I would like to set up macros to provide me with a
certain view for printing and research. Everytime I set up the macro and
protect the sheet it says that I can not use the macro.

Is there anyway around this or will I have to unprotect the sheet everytime
I want to use the macro? Any ideas or suggestions would be greatly
appreciated. Thank you.


--

Dave Peterson
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
checking that cells have a value before the workbook will close kcdonaldson Excel Worksheet Functions 8 December 5th 05 04:57 PM
Macro that password protects a sheet Ryan Excel Discussion (Misc queries) 1 November 10th 05 05:42 PM
Copy cell format to cell on another worksht and update automatical kevinm Excel Worksheet Functions 21 May 19th 05 11:07 AM
Copying multiple sheets from one book 2 another and undertake spec Pank Mehta Excel Discussion (Misc queries) 14 March 16th 05 04:41 PM
Can a macro format a hidden sheet? Robert Excel Discussion (Misc queries) 1 February 9th 05 06:13 PM


All times are GMT +1. The time now is 06:35 AM.

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

About Us

"It's about Microsoft Excel"