You unprotect a worksheet by using the object model, such as Worksheets("sheet2").Unprotect. If the unprotected worksheet is not the active worksheet, contents from the unprotected worksheet become visible on the current worksheet. This issue continues until there is an action that updates Excel.Resolution
To resolve this issue, apply the hotfix that is described in Microsoft Knowledge Base article 978522. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
Description of the Office Excel 2007 hotfix package (Excel-x-none.msp, Xlconv-x-none.msp): December 23, 2009
To work around this issue, minimize and then maximize the Excel window to redraw or refresh the Excel worksheet.Workaround 2
Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs.
If you have limited programming experience, you may want to contact a Microsoft Certified Partner or Microsoft Advisory Services. For more information, visit these Microsoft Web sites:
Microsoft Certified Partners - https://partner.microsoft.com/global/30000104
Microsoft Advisory Services - http://support.microsoft.com/gp/advisoryservice
For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS
To work around this issue, you can modify the macro code to work around this issue by activating the Excel worksheet before the Unprotect
method is run as shown in the following sample code.
Sub Button1_Click() Dim NowActiveSheet As WorkSheet Worksheets("sheet2").Protect Set NowActiveSheet=ActiveSheet ' Activate the Excel sheet before running Unprotect method. Worksheets("sheet2").Activate Worksheets("sheet2").Unprotect NowActiveSheet.ActivateEnd Sub
To work around this issue, activate all the worksheets in Excel manually or by using a macro after the issue has occurred.