I currently have a worksheet that I need to protect cells but allow for the user to use the dropdown selections in a few different ranges. The ranges have a variable column number since more columns can be added.
When I manually protect a worksheet and select the appropriate options, all cells are locked but the user can still select from the dropdowns in the necessary cells. However, when I lock the worksheet using VBA (which is necessary for some of my macros to function), this functionality dissapears.
All I'm doing in VBA is
'variable declarations
ws1.Unprotect Password:="pw"
ws1.Cells.Locked = False
'lots of code here
ws1.Cells.Locked = True
ws1.Protect Password:="pw", UserInterfaceOnly:=True, _
AllowDeletingColumns:=True, AllowFiltering:=True, AllowFormattingCells:=True,_
AllowFormattingColumns:=True, AllowUsingPivotTables:=True
I've read that AllowFiltering:=True
is what's supposed to allow for the dropdown selection in locked cells, but that doesn't seem to work here. Anyone know what the difference is between me manually locking and locking through vba?
ws1.Cells.Locked = True
, after executing none of the cells are locked. This is if I manually set the worksheet protection, and then have the code just sayws1.Unprotect Password :="pw"
.....code...ws1.Protect Password:="pw"
– Valkeif