If SelectedSheets.Count > 1, ActiveSheet.Unprotect fails.

B

bta

Reproduced with Excel 2007, 2003, 2002 and 2000.

How to reproduce:
1) Start Excel with a new clean unused workbook.
2) Add a couple of worksheets so that you have at least 3 worksheets.
3) Open the VBA editor and open ThisWorkbook.
4) Paste the following code into ThisWorkbook:

Private Sub Workbook_SheetActivate(ByVal work_sheet As Object)
work_sheet.Unprotect
work_sheet.Protect
End Sub

5) Go back to the Excel workbook and click each worksheet tab at least once
so that all worksheets get protected.
6) Select at least two worksheets.
7) Right-Click the tab of a NOT active worksheet, i.e. a worksheet which
name in the tab is not in bold.
8) A "Runtime error 1004: Unprotect method of worksheet object failed"
should appear.

Is this a bug or a feature?
Any suggestions for a workaround?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top