Ensure sheet is saved password Protected

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) )
 
A

Abdul Salam

Try this:


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

Abdul Salam
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top