View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
William[_2_] William[_2_] is offline
external usenet poster
 
Posts: 227
Default need code for disable selection of locked cells

hi David

This will only allow unlocked cells to be selected as long as the sheets are
protected. You code does not unprotect the sheets first (although you could
get around this by setting the userinterface to true).

Sub test()
Dim ws As Worksheet
For Each ws In Worksheets
With ws
..Unprotect
..EnableSelection = xlUnlockedCells
..Protect
End With
Next ws
End Sub

--
XL2002
Regards

William



"David Lewis" wrote in message
...
| Got code
| Sub protect()
|
| Dim ws As Worksheet
|
| For Each ws In ActiveWorkbook.Worksheets
| ws.EnableSelection = xlUnlockedCells
| ws.protect Password:=""
| Next ws
|
| End Sub
|
| I need to disable selection of locked cells
| Is there a function like ws.DisableSelection = xlLockedCells?
|