ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Protect Sheet Macro (https://www.excelbanter.com/excel-worksheet-functions/209371-protect-sheet-macro.html)

jrob54245

Protect Sheet Macro
 
I am trying to create a macro that will password protect the locked cells in
a spreadsheet. I can get the process to work, and the macro records, but
doesn't appear to be recording the actual process of applying the password.
In other words, I can just go in and unprotect the sheet, no password
required. Is it even possible to record the password into a macro, or does
that defeat the purpose?



Mike H

Protect Sheet Macro
 
Hi,

Try this

Sub sonic()
Dim sh As Worksheet
For Each sh In ThisWorkbook.Worksheets
sh.Protect Password:="MyPass"
Next
End Sub

Mike

"jrob54245" wrote:

I am trying to create a macro that will password protect the locked cells in
a spreadsheet. I can get the process to work, and the macro records, but
doesn't appear to be recording the actual process of applying the password.
In other words, I can just go in and unprotect the sheet, no password
required. Is it even possible to record the password into a macro, or does
that defeat the purpose?



jrob54245

Protect Sheet Macro
 
Thanks for the quick response. A couple of questions before I try your text.
Will it lock all worksheets at once? The workbook I am creating is for
planning purposes, 12 worksheets, one for each fiscal period. I have created
buttons on each sheet to allow one user to "lock" each estimate after the
period cutoff. Thus, the macro. I do need the sheets to be locked one at a
time though, and there are other worksheets in the book that should not be
protected at all.

Will your text still work? Sorry, this is new territory for me.
J
"Mike H" wrote:

Hi,

Try this

Sub sonic()
Dim sh As Worksheet
For Each sh In ThisWorkbook.Worksheets
sh.Protect Password:="MyPass"
Next
End Sub

Mike

"jrob54245" wrote:

I am trying to create a macro that will password protect the locked cells in
a spreadsheet. I can get the process to work, and the macro records, but
doesn't appear to be recording the actual process of applying the password.
In other words, I can just go in and unprotect the sheet, no password
required. Is it even possible to record the password into a macro, or does
that defeat the purpose?




All times are GMT +1. The time now is 11:20 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com