Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 71
Default EnableSelection Protecting sheet question

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?
  #2   Report Post  
Posted to microsoft.public.excel.misc
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?


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 71
Default EnableSelection Protecting sheet question

Gord,
I cant seem to change the letter"p" in .Protect to a capital "P".
It switches back to a lower case every time i change it. I tried everything.
and the code does not work it its in lower case.

Any idea why its going Loco?

Thanks.

"Gord Dibben" wrote:

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?



  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default EnableSelection Protecting sheet question

What happens when you copy/paste the code into the module?

On my end I can't get the upper case "P" to change to a lower case unless I
rem with an apostrophe.

Can't say I have seen this before.

Perhaps someone can explain for us.

One thing I did notice was that the code I posted did not set the password.

This revision does.

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


Gord


On Fri, 25 Sep 2009 07:48:01 -0700, Damian
wrote:

Gord,
I cant seem to change the letter"p" in .Protect to a capital "P".
It switches back to a lower case every time i change it. I tried everything.
and the code does not work it its in lower case.

Any idea why its going Loco?

Thanks.

"Gord Dibben" wrote:

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?




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
protecting formulas without protecting sheet so grouping still wor JM Excel Discussion (Misc queries) 1 June 4th 09 06:42 AM
Question about protecting P D Sterling New Users to Excel 2 June 27th 08 11:39 PM
Question about protecting a formula. tgcali Excel Discussion (Misc queries) 3 April 22nd 08 04:05 PM
Question about protecting charts Lauren Giles Excel Discussion (Misc queries) 2 March 2nd 07 12:34 AM
A question about locking or protecting a worksheet Meenie Excel Discussion (Misc queries) 2 February 8th 07 04:56 PM


All times are GMT +1. The time now is 10:25 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"