I'm trying to set up a workbook to allow my macros to run while protection is on (without a password). I've got the following code in the private module of ThisWorkbook.
Private Sub Workbook_Open()
Dim wSheet As Worksheet
For Each wSheet In Worksheets
When I run my macros, The ones that have query.refresh get the runtime error saying the cell I am trying to change is protected. Does UserInterFaceOnly not apply to query refresh?
Is there some other setting or code I need to make this work? Does it matter if I have protection on or off in each worksheet? I'm using Excel 2003. My query pulls data from a csv file.
My macros run fine if I unprotect every sheet manually and don't use the UserInterFaceOnly, but I need to have the sheets protected. I would rather not use protect/unprotect in the macro because if the macro gets terminated then protection is not set.