Is there a way in VBA to have user restricted to selecting only unlockedcells in a work sheetThks
Is there a way in VBA to have user restricted to selecting only unlockedcells in a work sheetThks
To enable only the unlocked cells to be selected:
[vba]Sub SelectOnlyUnlocked()
ActiveSheet.Protect
ActiveSheet.EnableSelection = xlUnlockedCells
End Sub[/vba]
To unprotect the sheet again:
[vba]Sub Unprotect()
ActiveSheet.Unprotect
End Sub[/vba]
sassora
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
very intuitively:
[vba]Private SubWorkbook_Open()
Worksheets("Vredenburg").EnableSelection = xlUnlockedCells
Worksheets("Malsmebury").EnableSelection = xlUnlockedCells
End Sub[/vba]
sassora
or you may wish to try
Private Sub Workbook_Open() With Worksheets("Vredenburg","Malsmebury") .EnableSelection = xlUnlockedCells End With End Sub
Remember To Do the Following....
Use [Code].... [/Code] tags when posting code to the thread.
Mark your thread as Solved if satisfied by using the Thread Tools options.
If posting the same issue to another forum please show the link