Thread: Locking Cells
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 Locking Cells

Phil

Assuming A1:A59 are unlocked and sheet is protected with a password of "justme"

User enters data in A1:A58 then enters name in A59.

Checker unprotects the sheet using password and enters name in A60.

The code below will re-protect the sheet with A1:A59 locked.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error GoTo enditall
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A60")) Is Nothing Then

With Target
If .Value < "" Then
Range("A1:A59").Cells.Locked = True
End If
End With
End If

enditall:
Application.EnableEvents = True
ActiveSheet.protect Password:="justme"
End Sub

This is sheet event code. Right-click on the sheet tab and "View Code"

Copy/paste the code into that sheet module.


Gord Dibben MS Excel MVP

On Wed, 6 Dec 2006 04:35:01 -0800, Phil wrote:

I have a spreadsheet where a person will enter a days data, A1:A58 and their
name in the next cell A59.

A second person will check the data and then enter their name in the next
cell A60.
(Cell A60 is password protected).

I would like entry of text into the specific cell (A60) to lock all others
above (A1:A59) in that column.

Is this possible?