Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 471
Default Global Book Protection

I have a workbook with 28 sheets in it. They are formatted pretty much the
same. I have gone through all of them and set up editable ranges so users
can enter data in certain areas. But in order to protect a sheet, I have to
protect each sheet individually. I can't protect the entire workbook. If I
use the Protect Workbook option, I can globally prevent users from removing
sheets or adding sheets, but I can't use that because it also denies the
ability to hide and display forms. It seems there is nothing that does what
I want: One command, One password to prevent users from changing all sheets
but still lets my macros which display forms to run. Also, if I use the
protect workbook command it does NOT protect the uneditable areas. If I
enable sheet protection 28 times, I will make mistakes on passwords. I
already did it once, typing the upper and lower cases backwards on one sheet.
Too much password maintenance!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Global Book Protection

Assuming they all share a password try this:-

Sub protect()
Dim wSheet As Worksheet
For Each wSheet In Worksheets
wSheet.Protect Password:="mypass"
Next wSheet
End Sub


Mike
"Mike H." wrote:

I have a workbook with 28 sheets in it. They are formatted pretty much the
same. I have gone through all of them and set up editable ranges so users
can enter data in certain areas. But in order to protect a sheet, I have to
protect each sheet individually. I can't protect the entire workbook. If I
use the Protect Workbook option, I can globally prevent users from removing
sheets or adding sheets, but I can't use that because it also denies the
ability to hide and display forms. It seems there is nothing that does what
I want: One command, One password to prevent users from changing all sheets
but still lets my macros which display forms to run. Also, if I use the
protect workbook command it does NOT protect the uneditable areas. If I
enable sheet protection 28 times, I will make mistakes on passwords. I
already did it once, typing the upper and lower cases backwards on one sheet.
Too much password maintenance!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 471
Default Global Book Protection

That is pretty cool. That is exactly what I wanted to be able to do. Thanks.

"Mike H" wrote:

Assuming they all share a password try this:-

Sub protect()
Dim wSheet As Worksheet
For Each wSheet In Worksheets
wSheet.Protect Password:="mypass"
Next wSheet
End Sub


Mike
"Mike H." wrote:

I have a workbook with 28 sheets in it. They are formatted pretty much the
same. I have gone through all of them and set up editable ranges so users
can enter data in certain areas. But in order to protect a sheet, I have to
protect each sheet individually. I can't protect the entire workbook. If I
use the Protect Workbook option, I can globally prevent users from removing
sheets or adding sheets, but I can't use that because it also denies the
ability to hide and display forms. It seems there is nothing that does what
I want: One command, One password to prevent users from changing all sheets
but still lets my macros which display forms to run. Also, if I use the
protect workbook command it does NOT protect the uneditable areas. If I
enable sheet protection 28 times, I will make mistakes on passwords. I
already did it once, typing the upper and lower cases backwards on one sheet.
Too much password maintenance!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Global Book Protection

Mike,
As you have found, WB protection does not achieve your aim, so you have to
use WS protection.
You can simplify the procedure, assuming you have the same PW for each
sheet:

Private Sub CommandButton1_Click()
Dim PW As String
Dim WS As Worksheet

Const STRING_ONLY As String = 2

PW = Application.InputBox("Enter the PW.", , , , , , STRING_ONLY)

If PW = "" Or PW = CStr(False) Then
MsgBox "No PW...."
Else
For Each WS In ThisWorkbook.Worksheets
WS.Protect PW
Next
End If

End Sub

And the opposite procedure to UnProtect the WSs.

NickHK

"Mike H." wrote in message
...
I have a workbook with 28 sheets in it. They are formatted pretty much

the
same. I have gone through all of them and set up editable ranges so users
can enter data in certain areas. But in order to protect a sheet, I have

to
protect each sheet individually. I can't protect the entire workbook. If

I
use the Protect Workbook option, I can globally prevent users from

removing
sheets or adding sheets, but I can't use that because it also denies the
ability to hide and display forms. It seems there is nothing that does

what
I want: One command, One password to prevent users from changing all

sheets
but still lets my macros which display forms to run. Also, if I use the
protect workbook command it does NOT protect the uneditable areas. If I
enable sheet protection 28 times, I will make mistakes on passwords. I
already did it once, typing the upper and lower cases backwards on one

sheet.
Too much password maintenance!



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
copy worksheets to new book without linking to original book Lori Excel Discussion (Misc queries) 2 March 4th 09 04:46 PM
Global Sheet Protection and a Button Finance Guru Excel Discussion (Misc queries) 8 November 2nd 07 07:57 AM
Open book, check for macros, close book Robin Hammond[_2_] Excel Programming 5 March 31st 05 06:09 PM
Sheet Protection and Book Recommendation kcc[_2_] Excel Programming 1 October 16th 04 08:50 PM
information From Global Address Book into list box. ELGIN Excel Programming 0 July 30th 04 05:05 AM


All times are GMT +1. The time now is 12:39 AM.

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

About Us

"It's about Microsoft Excel"