Data Protection

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:

  1. Open the VBA editor by pressing Alt + F11.
  2. Go to Insert > Module to insert a new module.
  3. Copy and paste the above code into the module.
  4. Replace "12345" with the password you want to use for protection.
  5. Close the VBA editor and return to Excel.
  6. Press Alt + F8, select ProtectAllWorksheets, and click Run.

This will protect all the worksheets in your workbook with the specified password.