View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rowan[_2_] Rowan[_2_] is offline
external usenet poster
 
Posts: 226
Default locking a cell after input

Right click the sheet tab, select View Code and paste this procedure into the
sheet code module:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Value 0 Then
Me.Unprotect
Target.Locked = True
Me.Protect
End If
End Sub

This will work if the sheet protection was set without a password. Otherwise
try:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Value 0 Then
Me.Unprotect Password:="mypassword"
Target.Locked = True
Me.Protect Password:="mypassword"
End If
End Sub

Hope this helps
Rowan

"bethg7" wrote:

I have a sheet that is protected except for one column that I need to put
sales receipts into. Is there a way for me to maybe do a conditional
formatting and have the cell locked after it's contents are 0.00? I am
using WinXP and Excel 2002