Macro isn't working after set .Protect UserInterfaceOnly:=True

Vladimir_Ludovic

New Member
Joined
May 1, 2014
Messages
3
Hello everyone,

This being my first post, I hope this forum can be helpfull to me, and I can to be helpfull to others. Please correct me if my style of posting is unclear or unjust.

I have a problem I am looking into for a day now, and still I can't lay my finger on it:

I have a data transfer macro, that writes cell data from a worksheet to another:
Code:
Sub cbxLocationLimits_Change()
    ' data laden vanaf Data_LocationLimits
    locrowcounter = Sheets("Data_LocationLimits").Range("A1").Value
    
    ' PRODUCT DATA
    For rowcounter = 0 To 6
        For columncounter = 0 To 1
            Sheets("InputSheet").Range("H5").Offset(rowcounter, columncounter).Value = _
            Sheets("Data_LocationLimits").Range("B3").Offset(locrowcounter - 1, 2 * rowcounter + columncounter).Value
        Next columncounter
    Next rowcounter
End Sub
When I open the document, following code is applied:

Code:
Private Sub Workbook_Open()
    Dim ws As Worksheet
     
    For Each ws In ThisWorkbook.Worksheets
        ws.Protect UserInterfaceOnly:=True
        ws.EnableAutoFilter = True
    Next ws


    ThisWorkbook.Protect Password:=strAdminPassword, Structure:=True, Windows:=False
        

End Sub

When I use the combobox that activates the sub, Excel 2010 returns a warning message about the worksheet being read only, and doesn't resolve the transfer action.

I can't figure out why, since I used the UserInterfaceOnly:=True Flag, right? Why would excel bother about protected worksheets?

I hope someone can shine light on this!
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
... When I use the combobox that activates the sub ...

Problem solved: The ComboBox requires an index, linked to a cell. That cell was on the same sheet as data source (and thus, protected). Changes applied through form objects are interpreted as 'User Input' and therefore not allowed. I unlocked that one cell, and that solved the problem. Little drawback still, is that the worksheet isn't protected entirely now, but well... not a major problem.
 
Upvote 0
Presuming the userform is Modal, why not unprotect the sheet(s) at the beginning of the combo box change event, and re-protect at the end?
 
Upvote 0
You are most welcome and thank you for the feedback.

Mark
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top