Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Multiple Worksheets - Protection

What is the most best way, with a macro, to Protect all worksheets in a
workbook using a popup asking for a password, and specify what functions a
users can use? And then to unlock it also, with a popup asking for the
password.

For example, I want to protect all the worksheets and have users be able to
"Select Unlocked Cells", "Select Locked Cells", and "Format Cells".

Also, to unprotect all the worksheets with a macro that pops up asking for
the password to unprotect all the sheets.

I hope that makes sense.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Multiple Worksheets - Protection

This should be close...

Sub ProtectAll()
Dim wks As Worksheet
Dim strPassword

strPassword = InputBox("Enter the password", "Password")

For Each wks In Worksheets
wks.EnableSelection = xlNoRestrictions
wks.Protect Password:=strPassword, _
Contents:=True, _
AllowFormattingCells:=True
Next wks
End Sub

Sub UnProtectAll()
Dim wks As Worksheet
Dim strPassword

strPassword = InputBox("Enter the password", "Password")

On Error Resume Next
For Each wks In Worksheets
wks.Unprotect Password:=strPassword
Next wks
On Error GoTo 0
End Sub
--
HTH...

Jim Thomlinson


"Josh O." wrote:

What is the most best way, with a macro, to Protect all worksheets in a
workbook using a popup asking for a password, and specify what functions a
users can use? And then to unlock it also, with a popup asking for the
password.

For example, I want to protect all the worksheets and have users be able to
"Select Unlocked Cells", "Select Locked Cells", and "Format Cells".

Also, to unprotect all the worksheets with a macro that pops up asking for
the password to unprotect all the sheets.

I hope that makes sense.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Multiple Worksheets - Protection

Thanks Jim.

"Jim Thomlinson" wrote:

This should be close...

Sub ProtectAll()
Dim wks As Worksheet
Dim strPassword

strPassword = InputBox("Enter the password", "Password")

For Each wks In Worksheets
wks.EnableSelection = xlNoRestrictions
wks.Protect Password:=strPassword, _
Contents:=True, _
AllowFormattingCells:=True
Next wks
End Sub

Sub UnProtectAll()
Dim wks As Worksheet
Dim strPassword

strPassword = InputBox("Enter the password", "Password")

On Error Resume Next
For Each wks In Worksheets
wks.Unprotect Password:=strPassword
Next wks
On Error GoTo 0
End Sub
--
HTH...

Jim Thomlinson


"Josh O." wrote:

What is the most best way, with a macro, to Protect all worksheets in a
workbook using a popup asking for a password, and specify what functions a
users can use? And then to unlock it also, with a popup asking for the
password.

For example, I want to protect all the worksheets and have users be able to
"Select Unlocked Cells", "Select Locked Cells", and "Format Cells".

Also, to unprotect all the worksheets with a macro that pops up asking for
the password to unprotect all the sheets.

I hope that makes sense.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Multiple Worksheets - Protection

Here is a link to some code to remove passwords for the case when someone can
not rememeber the password that they added...

http://www.mcgimpsey.com/excel/removepwords.html
--
HTH...

Jim Thomlinson


"Josh O." wrote:

Thanks Jim.

"Jim Thomlinson" wrote:

This should be close...

Sub ProtectAll()
Dim wks As Worksheet
Dim strPassword

strPassword = InputBox("Enter the password", "Password")

For Each wks In Worksheets
wks.EnableSelection = xlNoRestrictions
wks.Protect Password:=strPassword, _
Contents:=True, _
AllowFormattingCells:=True
Next wks
End Sub

Sub UnProtectAll()
Dim wks As Worksheet
Dim strPassword

strPassword = InputBox("Enter the password", "Password")

On Error Resume Next
For Each wks In Worksheets
wks.Unprotect Password:=strPassword
Next wks
On Error GoTo 0
End Sub
--
HTH...

Jim Thomlinson


"Josh O." wrote:

What is the most best way, with a macro, to Protect all worksheets in a
workbook using a popup asking for a password, and specify what functions a
users can use? And then to unlock it also, with a popup asking for the
password.

For example, I want to protect all the worksheets and have users be able to
"Select Unlocked Cells", "Select Locked Cells", and "Format Cells".

Also, to unprotect all the worksheets with a macro that pops up asking for
the password to unprotect all the sheets.

I hope that makes sense.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Protection on Worksheets Chris Excel Discussion (Misc queries) 6 February 9th 10 04:16 PM
Protection of worksheets Asiageek Charts and Charting in Excel 1 September 5th 07 05:34 PM
Protection Properties on WorkSheets spences10 Excel Programming 1 January 12th 07 12:31 PM
Protection of identical cells on multiple worksheets shawnlacey Excel Worksheet Functions 6 May 16th 06 09:08 PM
Cell Password Protection-Multiple Worksheets GW Trainer Excel Worksheet Functions 0 May 19th 05 07:58 PM


All times are GMT +1. The time now is 06:47 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"