ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to password protect several excel workbook pages using a macro (https://www.excelbanter.com/excel-programming/311658-how-password-protect-several-excel-workbook-pages-using-macro.html)

p88t

How to password protect several excel workbook pages using a macro
 
I can write a macro to protect lots of pages in a big workbook, but they are
protected without a password. How can I password protect them? I use Excel
2000.

Myrna Larson

How to password protect several excel workbook pages using a macro
 
In Help, look up the syntax for the Protect method of the worksheet. (In the
immediate window, type protect, then press F1.) Help has everything you want
to know.

On Mon, 27 Sep 2004 21:27:02 -0700, "p88t"
wrote:

I can write a macro to protect lots of pages in a big workbook, but they are
protected without a password. How can I password protect them? I use Excel
2000.



Gord Dibben

How to password protect several excel workbook pages using a macro
 
Assume by "pages" you mean "worksheets".

Sub ProtectAllSheets()
Application.ScreenUpdating = False
Dim N As Single
For N = 1 To Sheets.Count
Sheets(N).Protect Password:="justme"
Next N
Application.ScreenUpdating = True
End Sub

Sub UnprotectAllSheets()
Application.ScreenUpdating = False
Dim N As Single
For N = 1 To Sheets.Count
Sheets(N).Unprotect Password:="justme"
Next N
Application.ScreenUpdating = True
End Sub

Gord Dibben Excel MVP

On Mon, 27 Sep 2004 21:27:02 -0700, "p88t"
wrote:

I can write a macro to protect lots of pages in a big workbook, but they are
protected without a password. How can I password protect them? I use Excel
2000.




All times are GMT +1. The time now is 01:42 AM.

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