Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Conditional cell lock

1 view
Skip to first unread message

Doug Glancy

unread,
Mar 24, 2004, 5:49:22 PM3/24/04
to
Mike,

You could set the locked property of the formula cell based on the status of
the referenced cell. You can't change the locked status of a cell in a
protected sheet unless the sheet has been protected in code with the
Userinterfaceonly property set to True. Userinterfaceonly allows you to
change a protected sheet with code, although the user still can't. The
Userinterfaceonly setting is lost when the workbook is closed, so you need
to do it in code when the workbook is opened. Below is an example of these
two steps.

Private Sub Workbook_Open() ' insert this in the ThisWorkbook module,
not a regular module
Sheet1.Protect password:="drowsapp", userinterfaceonly:=True
End Sub

Sub test2()
If Sheet1.Range("A1") = True Then
Sheet1.Range("A2").Locked = False
Else
Sheet1.Range("A2").Locked = True
End If
End Sub

hth,

Doug

"Mike Rosenberg" <anon...@discussions.microsoft.com> wrote in message
news:D16DE8F7-2C89-405A...@microsoft.com...
> I would like to conditionally lock a cell in a protected worksheet. Here
is the example: I have a formula in cell to do a calculation. I want to
lock that cell so that the formula cannot be changed. However if a user
checks a forms box returning a "true" in the referenced cell, I want to be
able to override the formula. I see how to do this to conditionally format
font , border, or patterns, but not cell lock. Can this be done?


0 new messages