سؤال

I have quite a complicated workbook which i have very heavily locked down so it cant lose its structural integrity when being used by the user. It works like a dream in Excel 2003, 2007 and 2010 however when i use it in 2013 if i try and type in to an unprotected cell excel thinks that its protected, i can then unprotected the sheet manually and it still wont let me type in to the cell im then mysteriously allowed to unprotected the worksheet AGAIN and then it allows me to enter in to the cell and also get in to the cell formatting to demonstrate that the cell is definitely not locked. Its then made even more complicated when i then navigate to another protected sheet and i then find it unprotected.....

I have messed about with the sheet more and more and the problem appears to be when my macro moves me from one sheet to the next it believes its still on the previous sheet.

For example on the front sheet i have cell K16 as named cell called "ChangePW"

I then run my macro to select another sheet (shown below)

Application.ScreenUpdating = False
Sheets("Income&Expenditure").Select
Worksheets("Income&Expenditure").Unprotect Password:="*****"
Range("B3").Value = "OSC" 
Worksheets("Income&Expenditure").Protect Password:="*****"
Range("B2").Select
Application.ScreenUpdating = True

I then proceed to enter some data in to the the Income&Expenditure tab but i get a warning that the sheet is protected even though i have selected an unprotected cell. I then click on cell K16 on the Income&Expenditure sheet and it still thinks its called "ChangePW". As a result of this its applying the protection layout of the front sheet on the Income&Expenditure sheet. Even when i click on the Income&Expenditure tab at the bottom and click "Show Code" its showing me the code for the Front Sheet!!

All of the vba works perfectly in 2007 and 2010 so im absolutely stumped at the moment.

I have been navigating forums for the last 2 weeks trying to find an explanation with no successes, has anyone else experienced anything like this or know of a cause? i reiterate that it works perfectly in all other versions of Excel....

Thanks

هل كانت مفيدة؟

المحلول

I've been solving the same behaviour. The bug is in opening files from a modal UserForm. The solution is to open a UserForm as modeless. Either calling:

MyForm.Show False

or adding Layout event procedure to a UserForm:

Private Sub UserForm_Layout()
    Static fSetModal As Boolean
    If fSetModal = False Then
        fSetModal = True
        Me.Hide
        Me.Show 1
    End If
End Sub

Read: http://msdn.microsoft.com/en-us/library/office/dn251093.aspx

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top