Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 184
Default protect sheet macro problems

Hi,

I have a macro that runs to insert rows when a button is clicked in my
sheet. This works fine when the sheet is unprotected but not when the sheet
is protected. Is there a way to protect certain cells in my sheet but have
it unprotected so my macro works?

Nikki
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default protect sheet macro problems

Nikki

If running Excel 2002 or higher you should be able to Protect the sheet with
Allow insert rows enabled under ToolsProtectionProtect sheet.

If running an earlier version you will have to Unprotect in code then do the
inserting then re-protect.

Sub yourmacro()
ActiveSheet.Unprotect Password:="justme"
'do the inserting code
ActiveSheet..Protect Password:="justme"
End Sub


Gord Dibben MS Excel MVP

On Thu, 24 May 2007 17:08:03 -0700, Nikki
wrote:

Hi,

I have a macro that runs to insert rows when a button is clicked in my
sheet. This works fine when the sheet is unprotected but not when the sheet
is protected. Is there a way to protect certain cells in my sheet but have
it unprotected so my macro works?

Nikki


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,344
Default protect sheet macro problems

Hi Nikki,

It is not necessary to unprotect and reprotect a sheet to allow the macro to
run against it, instead protect the sheet with the VBA below:

ActiveSheet.Protect Password:="mypass", UserInterfaceOnly:=True

From the help system: UserInterfaceOnly Optional Variant True to protect the
user interface, but not macros. If this argument is omitted, protection
applies both to macros and to the user interface.
--
Cheers,
Shane Devenshire


"Nikki" wrote:

Hi,

I have a macro that runs to insert rows when a button is clicked in my
sheet. This works fine when the sheet is unprotected but not when the sheet
is protected. Is there a way to protect certain cells in my sheet but have
it unprotected so my macro works?

Nikki

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
Code to protect/unprotect a sheet using a macro with password FredH Excel Discussion (Misc queries) 5 October 23rd 07 04:49 PM
Protect sheet in macro traima Excel Worksheet Functions 3 March 9th 07 06:05 PM
Protect Workbook Vs Protect Sheet Poor_pakistani New Users to Excel 4 May 25th 06 02:06 PM
Can I protect columns w/in a "List" using Protect Sheet? Diane Excel Discussion (Misc queries) 0 May 10th 06 03:30 PM
Using macro to un/protect sheet Bonbon Excel Worksheet Functions 2 February 23rd 06 08:14 PM


All times are GMT +1. The time now is 09:52 AM.

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"