Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Protect All Sheets code not working
Thisworkbook refers to the workbook containing the code:
Sub ProtectSheets() Dim ws As Worksheet Application.ScreenUpdating = False For Each ws In ActiveWorkbook.Worksheets ws.Unprotect Password ws.Protect Password, True, True, True, True Next ws Application.ScreenUpdating = True End Sub -- Regards, Tom Ogilvy "Steve" wrote in message news:3ff2ed17$0$15602$afc38c87@... Hi everyone. I have the following code that protects all sheets in the workbook. I have now copied this code and inserted it into my personal workbook, so I can run it on all files. But it doesn't work. I'm assuming it is protecting and unprotecting sheets in my personal workbook only, and NOT the active workbook. What should I do? Thanks!! Sub ProtectSheets() Dim ws As Worksheet Application.ScreenUpdating = False For Each ws In ThisWorkbook.Worksheets ws.Unprotect Password ws.Protect Password, True, True, True, True Next ws Application.ScreenUpdating = True End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
protect VB-code | Excel Discussion (Misc queries) | |||
How to repeat a code for selected sheets (or a contiguous range of sheets) in a Workbook? | Excel Worksheet Functions | |||
Code to protect sheet | Excel Worksheet Functions | |||
password protect vba code | Excel Discussion (Misc queries) | |||
Protect Code | Excel Programming |