Protection

  • Thread starter Thread starter Eva Shanley
  • Start date Start date
E

Eva Shanley

Is there a way to programatically protect all the formulas
in a multiple sheet file, and also not allow row
insertions or deletions? TIA
 
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.
 
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
 
So I still need to unprotect the range a user can key into
first, correct?
 
Unlock, not unprotect.

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top