View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Ken Johnson Ken Johnson is offline
external usenet poster
 
Posts: 1,073
Default MACROS: Protect a cell depending on the value of another cell

Hi,
If you are wanting the macro to run automatically you could try this
code in the worksheet code module.
Copy the code then right click the sheet tab and select "View code"
from the popup menu. Paste the code into the code module that then
appears. Then press Alt + F11 to get out of the VBA Editor.
Don't forget to edit the password.

Private Sub Worksheet_Calculate()
Me.Unprotect "your password"
If Range("A2").Value < 0 Then
Range("A3").Locked = True
Else: Range("A3").Locked = False
End If
Me.Protect "your password"
End Sub

Ken Johnson