protecting sheets

G

Guest

Hi, I want to protect all my sheets but I have 255 in the workbook Is there
any way I can protect them all at once or do I have to do them one at a
time.I tried protecting the workbook but I could still change cells I wanted
to protect.


thanks in avance,
Wildauk.
 
G

Guest

Thy this:

Sub protectsheets()
For Each sht In Worksheets
sht.Protect
Next sht
End Sub

Dan
 
G

Guest

Actually, I forgot a "thisworkbook" reference to avoid protecting all
worksheets...

Sub protectsheets()
For Each sht In ThisWorkbook.Worksheets
sht.Protect
Next sht
End Sub

Note: you can add a lot of specifics to the protect method like passwords,
etc.
expression.Protect(Password, DrawingObjects, Contents, Scenarios,
UserInterfaceOnly)

See the VBA help for more info.

Dan
 
H

halimnurikhwan

Hi,
ThisWorkbook is a parent of sheets in ,
if you want to run it from other Workbook as AddIns,
just change ThisWorkbook to ActiveWorkbook you want to
protect the whole sheets in it.

thanks,

Hhalim

Dan Hatola menuliskan:
 

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

Top