VBA: How to access a specific range in a protected sheet without unprotecting it?
This might be a silly question, but I'm trying to configure I'm learning this framework and I'm trying to debug I'm working on a VBA project where I need to read values from specific ranges in a protected Excel sheet..... However, I'm working with a question because the sheet is protected, and I need to figure out how to access these ranges without unprotecting the sheet. I've tried using the 'UserInterfaceOnly' property when protecting the sheet, but it seems to not work as expected in my case. Here's how I have set up the protection: ```vba Sub ProtectSheet() With ThisWorkbook.Sheets("DataSheet") .Protect Password:="mypassword", UserInterfaceOnly:=True End With End Sub ``` I call this subroutine when opening the workbook. After that, I attempt to read values from cells A1 and B1 like this: ```vba Sub ReadValues() Dim valA As Variant Dim valB As Variant valA = ThisWorkbook.Sheets("DataSheet").Range("A1").Value valB = ThisWorkbook.Sheets("DataSheet").Range("B1").Value Debug.Print "Value in A1: " & valA Debug.Print "Value in B1: " & valB End Sub ``` When executing `ReadValues`, I get an behavior message: "Run-time behavior '1004': Unable to get the Range property of the Worksheet class". I've confirmed that the cells are not empty and the sheet is indeed protected. Is there a workaround to access these ranges without unprotecting the sheet entirely? Also, is there a way to set permissions so that certain ranges can be accessed while the sheet is still protected? Any guidance or code examples would be greatly appreciated. Any ideas how to fix this? I recently upgraded to Vba 3.10. How would you solve this? The project is a REST API built with Vba. This is part of a larger desktop app I'm building. I'm open to any suggestions. Any ideas what could be causing this?