ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Locking Cells (https://www.excelbanter.com/excel-discussion-misc-queries/121604-locking-cells.html)

phil

Locking Cells
 
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?

Gord Dibben

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?




All times are GMT +1. The time now is 12:54 PM.

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