Ensure sheet is saved password Protected

  • Thread starter Thread starter MrAlMackay
  • Start date Start date
M

MrAlMackay

All

Need to be able to protect my spreadsheet once it is closed down.

Is it possible to ensure to do the following:

1) With every sheet in workbook
- Protect all sheets
- Set password of "Test"

2) Would need this to happen when the spreadsheet is closed down, so assume I
could just put this in Auto_Close module?

I know its not normally advised to put the password within the module itself,
however need to ensure that the sheet is not shut down without being protected
first.

Appreciate any help you can offer on the above.

Many Thanks, Al Mackay ( (e-mail address removed) )
 
Try this:


Sub ProtectSheets()
strPWord = "Test"
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Protect strPWord
Next
End Sub

Abdul Salam
 
Back
Top