Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
West
 
Posts: n/a
Default How do I auto-protect a worksheet?

I have set my w/sheet to "protect" with some cell left "un-protected" for
easy data entry. I want to share my w/sheet and increase it's security level.
Is there a way to set the w/sheet on a "auto-protect" mode so that the file
is "protected" every time I close the file?. Using the manual "protect sheet"
is not so efficient as we tend to forget to "re-protect" it again when we
"unprotect" the w/sheet for maintainance purposes.
  #2   Report Post  
Rowan
 
Posts: n/a
Default

You could get excel to automatically protect sheets when the workbook is
closed. To do this you would use the workbook beforeclose event. Right Click
the Excel icon just to the left of the file menu. Select View Code to display
the Workbook code sheet. Paste this code into the sheet.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim sht As Worksheet
For Each sht In Worksheets
sht.Protect
Next sht
End Sub

This will protect every worksheet in your workbook. If you want to protect
just one sheet say "Sheet1" then the code should read:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Sheets("Sheet1").Protect
End Sub

Hope this helps
Rowan

"West" wrote:

I have set my w/sheet to "protect" with some cell left "un-protected" for
easy data entry. I want to share my w/sheet and increase it's security level.
Is there a way to set the w/sheet on a "auto-protect" mode so that the file
is "protected" every time I close the file?. Using the manual "protect sheet"
is not so efficient as we tend to forget to "re-protect" it again when we
"unprotect" the w/sheet for maintainance purposes.

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
Auto Protect workbook with password upon opening Brian Excel Worksheet Functions 0 February 23rd 05 05:45 PM
is there a way to protect a range of cells on a worksheet? vevans Excel Discussion (Misc queries) 1 February 17th 05 05:30 PM
lost my password (worksheet protect) Dan Winterton Excel Discussion (Misc queries) 1 January 18th 05 07:09 PM
How to protect Option button in worksheet Julie Excel Worksheet Functions 2 January 4th 05 01:01 AM
Auto Filter will not work in a new worksheet jess Excel Worksheet Functions 1 November 24th 04 11:09 AM


All times are GMT +1. The time now is 10:12 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"