I'm working on a protected Excel spreadsheet and ran into a problem with cells that I've programmatically locked that are still selectable. I can't click on them directly to select them, but if I select the cell to the lower right of a locked cell and then shift-click the one to the upper left, all 9 cells (including the 'locked' one) are selected. I can also click-drag to select the 9 cells. I'm using the following VBA code to protect and set the selection criteria:
Worksheets("Sheet1").Protect UserInterfaceOnly:=True
Worksheets("Sheet1").EnableSelection = xlUnlockedCells
I've tried the two commands in the reverse order and get the same results.
I've also used the Excel cell formatting / protection menus to do the same thing and get the same results.
Am I missing something obvious or is there some other programmatic way to mark a cell so that it can't be selected later on?