#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 109
Default Lock Cells

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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Lock Cells

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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 109
Default Lock Cells

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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Lock Cells

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
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
Lock Cells Snook Excel Discussion (Misc queries) 1 January 16th 08 06:41 PM
why do some cells not lock? CDecuir Excel Discussion (Misc queries) 1 April 16th 07 08:31 PM
How To Lock Cells Ziggy M Excel Discussion (Misc queries) 3 August 18th 06 02:24 PM
how can I lock certain cells? Linds Excel Discussion (Misc queries) 2 December 20th 05 10:46 PM
Lock Cells Diana Excel Discussion (Misc queries) 2 September 26th 05 07:27 PM


All times are GMT +1. The time now is 06:10 PM.

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"