Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Posts: 5
Default Code to protect all the worksheets in a book

Hi Experts,

I need a code to protect all the sheets in a workbook dynamically. i may add sheets or delete sheets but protection of the sheets should be dynamic.

thanks in advance.
  #2   Report Post  
Senior Member
 
Location: Hyderabad
Posts: 237
Thumbs up

Quote:
Originally Posted by bill_ball View Post
Hi Experts,

I need a code to protect all the sheets in a workbook dynamically. i may add sheets or delete sheets but protection of the sheets should be dynamic.

thanks in advance.
try this vba code in the VBE editor.

Sub ProtectAllSheets()
'Protects ALL worksheets
For Each Shts In ThisWorkbook.Worksheets
Shts.Protect Password:=secret
Next
End Sub.

if you are using excel 2007 version, copy this code to .xlsm (macro enabled) or excel 2003 you can directly copy to .xls spread sheet.

all the best
__________________
Thanks
Bala
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
Moving worksheets to another book - 2nd book will not appear jb0100 Excel Discussion (Misc queries) 2 March 18th 09 03:09 PM
copy worksheets to new book without linking to original book Lori Excel Discussion (Misc queries) 2 March 4th 09 04:46 PM
protect worksheet/book Gene Excel Worksheet Functions 2 December 16th 06 04:17 PM
how do I protect formula's only, not entire sheet or book? Beginner Excel User Setting up and Configuration of Excel 2 February 16th 06 09:07 PM
Can I protect a range of worksheets in a book with one action? Sussex Fran Excel Worksheet Functions 2 June 10th 05 03:02 PM


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

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"