ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Macro for protecting sheet (https://www.excelbanter.com/excel-discussion-misc-queries/167409-macro-protecting-sheet.html)

JoeP

Macro for protecting sheet
 
I have recorded a macro that protects a sheet. The coding that I have is

ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True

When I protect the sheet I want it so that only Unlocked cells can be
selected. My coding above does not do this.

What do I need to do to my code to make it so that a user cannot select
Unlocked cells, and only allow the user to select only Unlocked cells.

Thanks.

Dave Peterson

Macro for protecting sheet
 
look for enableselection in VBA's help.

You'll see a nice example.

JoeP wrote:

I have recorded a macro that protects a sheet. The coding that I have is

ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True

When I protect the sheet I want it so that only Unlocked cells can be
selected. My coding above does not do this.

What do I need to do to my code to make it so that a user cannot select
Unlocked cells, and only allow the user to select only Unlocked cells.

Thanks.


--

Dave Peterson

Gord Dibben

Macro for protecting sheet
 
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
ActiveSheet.EnableSelection = xlUnlockedCells


Gord Dibben MS Excel MVP

On Mon, 26 Nov 2007 15:06:01 -0800, JoeP wrote:

I have recorded a macro that protects a sheet. The coding that I have is

ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True

When I protect the sheet I want it so that only Unlocked cells can be
selected. My coding above does not do this.

What do I need to do to my code to make it so that a user cannot select
Unlocked cells, and only allow the user to select only Unlocked cells.

Thanks.




All times are GMT +1. The time now is 09:14 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com