#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Protection

Is there a way to programatically protect all the formulas
in a multiple sheet file, and also not allow row
insertions or deletions? TIA
  #2   Report Post  
Posted to microsoft.public.excel.programming
MDW MDW is offline
external usenet poster
 
Posts: 117
Default Protection

For Each Wks In Application.Workbooks(1).Worksheets

Wks.Protect "optionalpassword"

Next

Application.Workbooks(1).Protect "optionalpassword"

Note that cells need to be locked (which they are by default) for protection
to do anything about changing or hiding forumulas.

"Eva Shanley" wrote:

Is there a way to programatically protect all the formulas
in a multiple sheet file, and also not allow row
insertions or deletions? TIA

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Protection

for each sh in ActiveWorkbook.Worksheets
sh.Activate
set rng = nothing
if sh.Protectcontents then
sh.Unprotect password:="ABCD"
end if
On error resume next
set rng = sh.SpecialCells(xlFormulas)
On error goto 0
if not rng is nothing then _
rng.locked = True
sh.Protect Password:="ABCD"
Next

--
Regards,
Tom Ogilvy

"Eva Shanley" wrote in message
...
Is there a way to programatically protect all the formulas
in a multiple sheet file, and also not allow row
insertions or deletions? TIA



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Protection

So I still need to unprotect the range a user can key into
first, correct?

-----Original Message-----
for each sh in ActiveWorkbook.Worksheets
sh.Activate
set rng = nothing
if sh.Protectcontents then
sh.Unprotect password:="ABCD"
end if
On error resume next
set rng = sh.SpecialCells(xlFormulas)
On error goto 0
if not rng is nothing then _
rng.locked = True
sh.Protect Password:="ABCD"
Next

--
Regards,
Tom Ogilvy

"Eva Shanley" wrote

in message
...
Is there a way to programatically protect all the

formulas
in a multiple sheet file, and also not allow row
insertions or deletions? TIA



.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Protection

Unlock, not unprotect.

but the sheet can't be protected when you unlock the cells.

--
Regards,
Tom Ogilvy

"Eva Shanley" wrote in message
...
So I still need to unprotect the range a user can key into
first, correct?

-----Original Message-----
for each sh in ActiveWorkbook.Worksheets
sh.Activate
set rng = nothing
if sh.Protectcontents then
sh.Unprotect password:="ABCD"
end if
On error resume next
set rng = sh.SpecialCells(xlFormulas)
On error goto 0
if not rng is nothing then _
rng.locked = True
sh.Protect Password:="ABCD"
Next

--
Regards,
Tom Ogilvy

"Eva Shanley" wrote

in message
...
Is there a way to programatically protect all the

formulas
in a multiple sheet file, and also not allow row
insertions or deletions? TIA



.



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
Excel Data Protection Best Practice: AKA: Real Sheet Protection Mushman(Woof!)[_2_] Excel Discussion (Misc queries) 4 December 30th 09 01:20 AM
Excel Data Protection- AKA: Sheet/Macro Password Protection Mushman(Woof!) Setting up and Configuration of Excel 0 December 29th 09 06:50 AM
WS Protection: Different Levels of Protection on Different Ranges Carmi Excel Discussion (Misc queries) 4 August 31st 07 02:26 PM
Cell Protection vs. Worksheet Protection kmwhitt Excel Discussion (Misc queries) 4 September 24th 06 02:37 AM
Worksheet protection is gone and only wokbook protection can be se Eric C. Excel Discussion (Misc queries) 4 May 2nd 06 04:50 PM


All times are GMT +1. The time now is 11:15 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"