PDA

View Full Version : [SOLVED:] Select only Unlocked cell



BENSON
12-07-2013, 02:28 AM
Is there a way in VBA to have user restricted to selecting only unlockedcells in a work sheetThks

sassora
12-07-2013, 07:35 AM
To enable only the unlocked cells to be selected:
Sub SelectOnlyUnlocked()
ActiveSheet.Protect
ActiveSheet.EnableSelection = xlUnlockedCells
End Sub

To unprotect the sheet again:
Sub Unprotect()
ActiveSheet.Unprotect
End Sub

BENSON
12-08-2013, 03:18 AM
Thks for code sassora,I did find the code below prior to your reply which works on the sheet called Vredenburg.However I have added another sheet called Malsmebury and the code does not work on it can anyone help.


Private Sub Workbook_Open()
Worksheets("Vredenburg").EnableSelection = xlUnlockedCells

End Sub

sassora
12-08-2013, 03:53 AM
very intuitively:

Private SubWorkbook_Open()
Worksheets("Vredenburg").EnableSelection = xlUnlockedCells
Worksheets("Malsmebury").EnableSelection = xlUnlockedCells
End Sub

Aussiebear
12-08-2013, 06:43 AM
or you may wish to try


Private Sub Workbook_Open()
With Worksheets("Vredenburg","Malsmebury")
.EnableSelection = xlUnlockedCells
End With
End Sub