1) Make Excel Sheet Read only.
Review tab -> Protect Sheet.
2) Make your Excel Workbook Partial Protected
i) Select the table -> Right Click -> Format Cells -> Change Protection Check Box.
Review tab -> Protect Sheet.
3) Protect Structure or Worksheet.
Review tab -> Protect Workbook -> Type Password
4) Set Opening Password
File -> Save As -> (On Save as dialog Box Select Password Option ->Enter the Password -> Re Enter Password -> OK
How to hide or unhide multiple sheets using VBA
Sub ProtectAllWorksheets()
Dim ws As Worksheet
Dim pwd As String
‘ Set the password for protection
pwd = “12345”
‘ Loop through all the worksheets in the workbook
For Each ws In ThisWorkbook.Worksheets
‘ Protect the worksheet with the password
ws.Protect Password:=pwd
Next ws
MsgBox “All worksheets have been protected.”, vbInformation
End Sub
Sub UnProtectAllWorksheets()
Dim ws As Worksheet
Dim pwd As String
‘ Set the password for protection
pwd = “123456”
‘ Loop through all the worksheets in the workbook
For Each ws In ThisWorkbook.Worksheets
‘ Protect the worksheet with the password
ws.Unprotect Password:=pwd
Next ws
MsgBox “All worksheets have been protected.”, vbInformation
End Sub
How to Use:
- Open the VBA editor by pressing
Alt + F11
. - Go to
Insert
>Module
to insert a new module. - Copy and paste the above code into the module.
- Replace
"12345"
with the password you want to use for protection. - Close the VBA editor and return to Excel.
- Press
Alt + F8
, selectProtectAllWorksheets
, and clickRun
.
This will protect all the worksheets in your workbook with the specified password.