Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
CLR CLR is offline
external usenet poster
 
Posts: 1,998
Default Auto-Protect multiple Sheets on closing?

Hi All......
I have a workbook with three sheets, Sheet1, Sheet2, and Sheet3.... When a
user opens the book, they find all sheets protected with their individual
passwords, (PW1, PW2, and PW3 respectively). The authorized users know the
passwords and will unprotect one or more sheets to edit them. If someone
would be so kind, I would like a "BeforeClose" macro that would reset the
protection on all sheets using the proper passwords. I've tried recording
one but it don't pick up the passwords.

TIA
Vaya con Dios,
Chuck, CABGx3


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Auto-Protect multiple Sheets on closing?

Private Sub Workbook_BeforeClose(Cancel As Boolean)
With thisWorkbook
.worksheets("sheet1").Protect Password:="ABC1"
.Worksheets("sheet2").Protect Password:="EFGH"
.Worksheets("Sheet3").Protect Password:="Snodgrass"
End With
Application.EnableEvents = False
Thisworkbook.Save
Application.EnableEvents = True
End sub

Would be the basic code.

--
Regards,
Tom Ogilvy


"CLR" wrote:

Hi All......
I have a workbook with three sheets, Sheet1, Sheet2, and Sheet3.... When a
user opens the book, they find all sheets protected with their individual
passwords, (PW1, PW2, and PW3 respectively). The authorized users know the
passwords and will unprotect one or more sheets to edit them. If someone
would be so kind, I would like a "BeforeClose" macro that would reset the
protection on all sheets using the proper passwords. I've tried recording
one but it don't pick up the passwords.

TIA
Vaya con Dios,
Chuck, CABGx3


  #3   Report Post  
Posted to microsoft.public.excel.programming
CLR CLR is offline
external usenet poster
 
Posts: 1,998
Default Auto-Protect multiple Sheets on closing?

As usual, your stuff works like a charm Tom.........many thanks!

Vaya con Dios,
Chuck, CABGx3



"Tom Ogilvy" wrote:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
With thisWorkbook
.worksheets("sheet1").Protect Password:="ABC1"
.Worksheets("sheet2").Protect Password:="EFGH"
.Worksheets("Sheet3").Protect Password:="Snodgrass"
End With
Application.EnableEvents = False
Thisworkbook.Save
Application.EnableEvents = True
End sub

Would be the basic code.

--
Regards,
Tom Ogilvy


"CLR" wrote:

Hi All......
I have a workbook with three sheets, Sheet1, Sheet2, and Sheet3.... When a
user opens the book, they find all sheets protected with their individual
passwords, (PW1, PW2, and PW3 respectively). The authorized users know the
passwords and will unprotect one or more sheets to edit them. If someone
would be so kind, I would like a "BeforeClose" macro that would reset the
protection on all sheets using the proper passwords. I've tried recording
one but it don't pick up the passwords.

TIA
Vaya con Dios,
Chuck, CABGx3


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
Are there ways to protect multiple sheets at once? Monty New Users to Excel 3 May 29th 08 11:57 PM
Macro to protect multiple sheets? Stilla Excel Worksheet Functions 12 March 5th 07 07:03 PM
How do I protect multiple sheets at one time? Kelly Excel Worksheet Functions 1 February 27th 06 04:30 PM
Protect multiple sheets in one time Henk Frigge Excel Programming 4 June 29th 05 01:16 PM
How do I protect formula cells on multiple sheets? Webdiva Excel Worksheet Functions 0 May 3rd 05 08:29 PM


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