![]() |
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 |
All times are GMT +1. The time now is 02:05 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com