Protect all sheets at once

This tutorial shows how to protect all sheets in a single workbook at once through the use of VBA

METHOD 1. Protect all sheets at once using VBA

VBA

Sub Protect_All_Sheets()
'declare a variable
Dim ws As Worksheet
'loop through each worksheet in this workbook and password protect them
For Each ws In ThisWorkbook.Worksheets

ws.Protect Password:="Pword"

Next ws

End Sub

ADJUSTABLE PARAMETERS
Password: Enter the password that you want to protect each of the sheets in the workbook with by changing "Pword" in the VBA code.

Explanation about how to protect all sheets at once

EXPLANATION

EXPLANATION

This tutorial shows how to password protect all of the sheets in a single workbook at once through the use of VBA. The VBA code loops through each of the sheets in a workbook and applies a password to each one. In this example the same password is used to protect each sheet in the workbook where the VBA code is written.

RELATED TOPICS

Related Topic Description Related Topic and Description
How to protect a single sheet in a workbook using Excel or VBA
How to unprotect a single sheet in a workbook using Excel or VBA
How to unprotect all protected sheets in a single workbook at once through the use of VBA