K
Ken Johnson
xl2003, Windows XP:
Sub SaveSelectUnlocked()
Dim SaveAsFilename
ActiveSheet.Unprotect
With Range("A1,B2,C3")
.Locked = False
.FormulaHidden = False
End With
With ActiveSheet
.EnableSelection = xlUnlockedCells
.Protect
End With
ActiveWorkbook.Protect
SaveAsFilename = Application.GetSaveAsFilename(InitialFileName:="")
If SaveAsFilename <> False Then ActiveWorkbook.SaveAs (SaveAsFilename)
End Sub
I was hoping the above code would result in a SavedAs copy of the
workbook with the only selectable cells being A1, B2 and C3. As soon
as the code has finished running that is the case. However, after
closing and reopening the workbook, all cells are selectable. Even
manually saving the workbook resulting from the code, closing and
reopening results in all cells being selectable.
Is there a way of programatically limiting a worksheet's selection
range to unlocked cells so that it is retained between sessions?
Ken Johnson
Sub SaveSelectUnlocked()
Dim SaveAsFilename
ActiveSheet.Unprotect
With Range("A1,B2,C3")
.Locked = False
.FormulaHidden = False
End With
With ActiveSheet
.EnableSelection = xlUnlockedCells
.Protect
End With
ActiveWorkbook.Protect
SaveAsFilename = Application.GetSaveAsFilename(InitialFileName:="")
If SaveAsFilename <> False Then ActiveWorkbook.SaveAs (SaveAsFilename)
End Sub
I was hoping the above code would result in a SavedAs copy of the
workbook with the only selectable cells being A1, B2 and C3. As soon
as the code has finished running that is the case. However, after
closing and reopening the workbook, all cells are selectable. Even
manually saving the workbook resulting from the code, closing and
reopening results in all cells being selectable.
Is there a way of programatically limiting a worksheet's selection
range to unlocked cells so that it is retained between sessions?
Ken Johnson