ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Protect sheets before close (https://www.excelbanter.com/excel-programming/384273-protect-sheets-before-close.html)

Saintsman

Protect sheets before close
 
How do I protect (no password needed) specific sheets - say sheet 1; 3 & 6
when a spreadsheet is closed?
Ideally I would like to use sheet reference rather than name



Jim Thomlinson

Protect sheets before close
 
What you are looking for is the workbook level events stored in thisworkbook
(right click on the XL icon next to the word file in the menu bar and select
View Code). Add code something like this assuming that you have not changed
the code names of the sheets...

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Sheet1.Protect
Sheet3.Protect
End Sub
--
HTH...

Jim Thomlinson


"Saintsman" wrote:

How do I protect (no password needed) specific sheets - say sheet 1; 3 & 6
when a spreadsheet is closed?
Ideally I would like to use sheet reference rather than name



Saintsman

Protect sheets before close
 
Thanks very much for quick response & helpful answer

"Jim Thomlinson" wrote:

What you are looking for is the workbook level events stored in thisworkbook
(right click on the XL icon next to the word file in the menu bar and select
View Code). Add code something like this assuming that you have not changed
the code names of the sheets...

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Sheet1.Protect
Sheet3.Protect
End Sub
--
HTH...

Jim Thomlinson


"Saintsman" wrote:

How do I protect (no password needed) specific sheets - say sheet 1; 3 & 6
when a spreadsheet is closed?
Ideally I would like to use sheet reference rather than name




All times are GMT +1. The time now is 11:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com