Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Dear all,
I wonder if someone could help? I have a range of cells, B2:AY51, I wish to select all the range and 'lock' them for protection. Then I'd like to 'unlock' only those that are red. Thanking-you in advance, Kind regards, Neil |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
What about all the other cells on the worksheet? Locked or unlocked?
Are the red cells within the B2:AY51 range or? How did those cells get to be colored red? Gord Dibben MS Excel MVP On Wed, 30 Apr 2008 12:14:01 -0700, Neil Pearce wrote: Dear all, I wonder if someone could help? I have a range of cells, B2:AY51, I wish to select all the range and 'lock' them for protection. Then I'd like to 'unlock' only those that are red. Thanking-you in advance, Kind regards, Neil |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Good evening Gorden,
The range is B1:AY51. The red cells do lie in the this range, there may be red cellsoutside of this too bu they do not require locking necessarily. Teh range has been copied and pasted from another workbook, i.e it would take an age to indiviually select all the red cells. Other cells on the worksheet are both locked and unlocked are requried not to be altered. I would hazzard a guess that the answer would be along the lines of: (although I know not how to write it, or any code as yet) Sub (Unprotect Red) Define Range For each cell in range If red unlock If not red lock End Kindest of regards, Neil "Gord Dibben" wrote: What about all the other cells on the worksheet? Locked or unlocked? Are the red cells within the B2:AY51 range or? How did those cells get to be colored red? Gord Dibben MS Excel MVP On Wed, 30 Apr 2008 12:14:01 -0700, Neil Pearce wrote: Dear all, I wonder if someone could help? I have a range of cells, B2:AY51, I wish to select all the range and 'lock' them for protection. Then I'd like to 'unlock' only those that are red. Thanking-you in advance, Kind regards, Neil |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Try this worksheet_activate code.
When you select the worksheet, the event code runs. Private Sub Worksheet_Activate() Dim rng As Range With Me .Unprotect Password:="justme" .Range("B2:AY51").Cells.Locked = True For Each rng In .Range("B2:AY51") If rng.Interior.ColorIndex = 3 Then rng.Locked = False End If Next rng .Protect Password:="justme" End With End Sub Right-click on the sheet tab and "View code". Copy/paste the code into that worksheet module. Alt + q to return to the Excel window. Switch to another sheet then back to this sheet. Test the "lockedness" of the red cells vs non-red cells by typing in them. Gord On Wed, 30 Apr 2008 15:18:00 -0700, Neil Pearce wrote: Good evening Gorden, The range is B1:AY51. The red cells do lie in the this range, there may be red cellsoutside of this too bu they do not require locking necessarily. Teh range has been copied and pasted from another workbook, i.e it would take an age to indiviually select all the red cells. Other cells on the worksheet are both locked and unlocked are requried not to be altered. I would hazzard a guess that the answer would be along the lines of: (although I know not how to write it, or any code as yet) Sub (Unprotect Red) Define Range For each cell in range If red unlock If not red lock End Kindest of regards, Neil "Gord Dibben" wrote: What about all the other cells on the worksheet? Locked or unlocked? Are the red cells within the B2:AY51 range or? How did those cells get to be colored red? Gord Dibben MS Excel MVP On Wed, 30 Apr 2008 12:14:01 -0700, Neil Pearce wrote: Dear all, I wonder if someone could help? I have a range of cells, B2:AY51, I wish to select all the range and 'lock' them for protection. Then I'd like to 'unlock' only those that are red. Thanking-you in advance, Kind regards, Neil |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Lock Cells | Excel Discussion (Misc queries) | |||
why do some cells not lock? | Excel Discussion (Misc queries) | |||
How To Lock Cells | Excel Discussion (Misc queries) | |||
how can I lock certain cells? | Excel Discussion (Misc queries) | |||
Lock Cells | Excel Discussion (Misc queries) |