#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 440
Default protected sheets

Hi,
In a workbook with many worksheets, all of which are protected, I was
wondering if it was possible to display (perhaps in A1) a letter or symbol to
indicate if the sheet you're looking at is protected or not. After making
changes to various sheets, I then have to check each one to ensure I have
reset the protection.

Thanks
--
Traa Dy Liooar

Jock
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default protected sheets

Jock,

I don't believe that protecting a sheet fires any of the workbook/worksheet
events. You could try this which will write the protection status of each
worksheet to A1 of that sheet. When you think you've protected each sheet you
can run it again to confirm it.

Sub stance()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
If ws.ProtectContents = True Then
ws.Unprotect Password:="Mypass"
ws.Range("A1").Value = "Protected"
ws.Protect Password:="Mypass"
Else
ws.Range("A1").Value = "Unprotected"
flag = flag + 1
End If
Next ws
MsgBox "There are " & flag & " Unprotected worksheets"
End Sub

Mike

"Jock" wrote:

Hi,
In a workbook with many worksheets, all of which are protected, I was
wondering if it was possible to display (perhaps in A1) a letter or symbol to
indicate if the sheet you're looking at is protected or not. After making
changes to various sheets, I then have to check each one to ensure I have
reset the protection.

Thanks
--
Traa Dy Liooar

Jock

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 440
Default protected sheets

Good job as usual, Mike.
Thanks
--
Traa Dy Liooar

Jock


"Mike H" wrote:

Jock,

I don't believe that protecting a sheet fires any of the workbook/worksheet
events. You could try this which will write the protection status of each
worksheet to A1 of that sheet. When you think you've protected each sheet you
can run it again to confirm it.

Sub stance()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
If ws.ProtectContents = True Then
ws.Unprotect Password:="Mypass"
ws.Range("A1").Value = "Protected"
ws.Protect Password:="Mypass"
Else
ws.Range("A1").Value = "Unprotected"
flag = flag + 1
End If
Next ws
MsgBox "There are " & flag & " Unprotected worksheets"
End Sub

Mike

"Jock" wrote:

Hi,
In a workbook with many worksheets, all of which are protected, I was
wondering if it was possible to display (perhaps in A1) a letter or symbol to
indicate if the sheet you're looking at is protected or not. After making
changes to various sheets, I then have to check each one to ensure I have
reset the protection.

Thanks
--
Traa Dy Liooar

Jock

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default protected sheets

Your welcome Jock and thanks for the feedback.

Mike

"Jock" wrote:

Good job as usual, Mike.
Thanks
--
Traa Dy Liooar

Jock


"Mike H" wrote:

Jock,

I don't believe that protecting a sheet fires any of the workbook/worksheet
events. You could try this which will write the protection status of each
worksheet to A1 of that sheet. When you think you've protected each sheet you
can run it again to confirm it.

Sub stance()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
If ws.ProtectContents = True Then
ws.Unprotect Password:="Mypass"
ws.Range("A1").Value = "Protected"
ws.Protect Password:="Mypass"
Else
ws.Range("A1").Value = "Unprotected"
flag = flag + 1
End If
Next ws
MsgBox "There are " & flag & " Unprotected worksheets"
End Sub

Mike

"Jock" wrote:

Hi,
In a workbook with many worksheets, all of which are protected, I was
wondering if it was possible to display (perhaps in A1) a letter or symbol to
indicate if the sheet you're looking at is protected or not. After making
changes to various sheets, I then have to check each one to ensure I have
reset the protection.

Thanks
--
Traa Dy Liooar

Jock

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
protected sheets Aspen Excel Discussion (Misc queries) 1 November 11th 06 08:05 PM
sorting protected sheets esslingerdav Excel Worksheet Functions 1 September 23rd 06 09:06 AM
Protected Sheets Jolo Excel Discussion (Misc queries) 3 December 28th 05 02:21 AM
Protected sheets HRMSN Excel Worksheet Functions 1 November 8th 05 10:19 PM
Protected sheets steve Excel Worksheet Functions 2 November 14th 04 05:53 PM


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

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"