password protect excel vba code example
Example 1: excel vba password protect
' Password for opening
ThisWorkbook.SaveAs Password:="my_password"
' Access granted, password required for modification
ThisWorkbook.SaveAs writeResPassword:="my_password2"
Example 2: excel vba protect worksheet without password
Worksheets("Sheet1").Unprotect "Password"