![]() |
Need code to protect worksheets - amount of worksheets varies
Hello!
I need code that will protect worksheets and the workbook. There are many workbooks involved and depending on the particular workbook, it will have X amount of worksheets in it with various names. Also, I need to hide certain sheets in each workbook - those will always be the same. Any suggestions will be greatly appreciated! Sandy |
Need code to protect worksheets - amount of worksheets varies
heres a macro that i use all the time
this protects all the sheets and the workbook Sub protect() Dim i As Integer ' Loop through all sheets in the workbook. ' change this for the number of sheets For i = 1 To Sheets.Count Sheets(i).protect "PASSWORD", True, True, True 'Range("A1").Select Next i 'protect workbook ActiveWorkbook.protect Structu=True, Windows:=False ActiveWorkbook.protect "PASSWORD", True, False End Sub Sub unprotect() Dim i As Integer ' Loop through all sheets in the workbook. ' this can also be set to a number For i = 1 To Sheets.Count Sheets(i).unprotect "PASSWORD" 'Range("A1").Select Next i ActiveWorkbook.unprotect "PASSWORD" End Sub hope this helps kevin "Sandy" wrote in message ... Hello! I need code that will protect worksheets and the workbook. There are many workbooks involved and depending on the particular workbook, it will have X amount of worksheets in it with various names. Also, I need to hide certain sheets in each workbook - those will always be the same. Any suggestions will be greatly appreciated! Sandy |
All times are GMT +1. The time now is 06:43 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com