Protect sheets in one go

  • Thread starter Thread starter mohavv
  • Start date Start date
M

mohavv

Hi,

Is there a way to protect all the sheets in a workbook in one go?
I've got 17-19 sheets (it varies).

I could create a macro, but how to handle the different number of
sheets?

Cheers,

Harold
 
something like
for each ws in worksheets
if ws.name<>"notthisone" _
and ws.name <>"notthisoneeither" then
end if
ws.protect
next ws
 
This will do them all...

Sub ProtectAll()
dim wks as worksheet

for each wks in worksheets
wks.protect Password:="Tada"
next wks
end sub
 
or perhaps...

for each ws in worksheets
if ws.name<>"notthisone" _
and ws.name <>"notthisoneeither" then
ws.protect
end if
next ws
 
This will do them all...

Sub ProtectAll()
dim wks as worksheet

for each wks in worksheets
 wks.protect Password:="Tada"
next wks
end sub
--
HTH...

Jim Thomlinson







- Show quoted text -

Tx! works fine!
 

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