Share via

Can you protect and unprotect all the sheets in a book at once

Anonymous
2015-11-22T12:51:48+00:00

I have several books and I protect each sheet in the book.  When I have to work on the sheets I unprotect them.  Can I do this all at once or do I have to each sheet?  If I protect the entire book does that do all the sheets and may be  better way of protection?

Thanks

I have Office 2010-2013-2016

windows 7 and 8.1

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

HansV 462.6K Reputation points
2015-11-22T13:14:54+00:00

Protecting a workbook has a different effect than protecting individual sheets.

You can use macros to protect/unprotect all worksheets:

Sub ProtectAll()

    Dim wsh As Worksheet

    For Each wsh In Worksheets

        wsh.Protect Password:="Secret"

    Next wsh

End Sub

Sub UnprotectAll()

    Dim wsh As Worksheet

    For Each wsh In Worksheets

        wsh.Unprotect Password:="Secret"

    Next wsh

End Sub

If you wish, you can assign these macros to custom Quick Access Toolbar buttons and/or custom keyboard shortcuts.

Was this answer helpful?

40+ people found this answer helpful.
0 comments No comments

Answer accepted by question author

HansV 462.6K Reputation points
2015-11-23T16:14:23+00:00

By default, all cells are locked, but this only becomes effective when you protect the sheet.

You have to select the cells/ranges that the user must be able to edit.

Press Ctrl+1 to activate the Format Cells dialog.

Activate the Protection tab.

Clear the Locked check box.

Click OK.

Repeat this for each sheet.

Then run the ProtectAll macro, after changing "Secret" to the password that you want to use. The macro will loop through all the worksheets and protect them with the password that you provided.

Don't forget to change "Secret" in the UnprotectAll macro too: the password to unprotect must be the same as the password you protected the sheets with, of course.

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2015-11-23T12:50:02+00:00

    Hans,

    thanks for the reply and help.    Do I set up my sheets for protection the way I normally would and then run this Macro and it protects the areas I tell it to protect? Will the Macro allow a password to Unprotect and protect?  How dies it work ?

    thanks again

    Was this answer helpful?

    0 comments No comments