View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default EnableSelection Protecting sheet question

Yes, you are using the code wrong.

With ActiveSheet
.Protect Password:="xxx"
.EnableSelection = xlUnlockedCells
.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowFormattingRows:=True
End With

Recording a macro whilst protecting the sheet would have shown you the code.


Gord Dibben MS Excel MVP

On Thu, 24 Sep 2009 13:50:02 -0700, Damian
wrote:

I have a sheet which I need to protect:
I have this code (VBA)
With ActiveSheet
.Protect Password:="xxx"
.EnableSelection = xlUnlockedCells
End With

AND it works great. BUT I need to add to this so they cab use FormatCells,
FormatColumns and FormatRows.
When I wrote this:
With ActiveSheet
.Protect Password:="xxx"
.EnableSelection = xlUnlockedCells
.EnableSelection = xlFormatCells
.EnableSelection = xlFormatColumns
.EnableSelection = xlFormatRows
End With

IT DOES NOT WORK. Am I doing the code wrong?