protect workbook

J

JB

Hello.

I have a file that has 7 sheets. I want to protect it so that it can be
viewed but not edited.
I know how to do this by sheet but when I do 'protect workbook' it makes no
difference. how do you do it in one go rather than going into every sheet
and protecting it and then having to unprotect 7 times when I'm using it.

Thank you
 
K

Ken Johnson

Hello.

I have a file that has 7 sheets. I want to protect it so that it can be
viewed but not edited.
I know how to do this by sheet but when I do 'protect workbook' it makes no
difference. how do you do it in one go rather than going into every sheet
and protecting it and then having to unprotect 7 times when I'm using it.

Thank you

Use macros to protect and unprotect all the sheets. Maybe...

Public Sub ProtectAllSheets()
Application.ScreenUpdating = False
Dim Sht As Object
On Error Resume Next
For Each Sht In ThisWorkbook.Sheets
Sht.Protect "password" 'change to your password
Next Sht
End Sub

Public Sub UnProtectAllSheets()
Application.ScreenUpdating = False
Dim Sht As Object
On Error Resume Next
For Each Sht In ThisWorkbook.Sheets
Sht.Unprotect "password" 'change to your password
Next Sht
End Sub
 
J

JB

Thank you I'll try that

Ken Johnson said:
Use macros to protect and unprotect all the sheets. Maybe...

Public Sub ProtectAllSheets()
Application.ScreenUpdating = False
Dim Sht As Object
On Error Resume Next
For Each Sht In ThisWorkbook.Sheets
Sht.Protect "password" 'change to your password
Next Sht
End Sub

Public Sub UnProtectAllSheets()
Application.ScreenUpdating = False
Dim Sht As Object
On Error Resume Next
For Each Sht In ThisWorkbook.Sheets
Sht.Unprotect "password" 'change to your password
Next Sht
End Sub
 

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