![]() |
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. |
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. |
All times are GMT +1. The time now is 02:38 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com