View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Ken Johnson Ken Johnson is offline
external usenet poster
 
Posts: 1,073
Default Keep Cell Unlocked but Don't Allow User to Change the Text inCell

On May 13, 11:03 pm, RyanH wrote:
I have a UserForm that adds and edits data on a worksheet. To load the
UserForm the user Double Clicks a cell that contains a reference number, the
macro searchs for the reference number in another worksheet and loads the
UserForm with the associated data. I have to keep the cell unlocked so the
user can double click it. The problem is that it is possible for the user to
delete the reference number. Is there a way to keep that cell from being
changed and still allow my Double Click Event to work?


I'm not sure if this helps, but I just had all cells locked and the
sheet protected with users allowed to Select locked cells and Select
unlocked cell as the only options (Excel 03).
When I ran this...

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel
As Boolean)
Application.DisplayAlerts = False
MsgBox Target.Value
End Sub

the msgbox showed the Target value then after I clicked OK the
protection alert was shown.

However, when I changed the code to...

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel
As Boolean)
Application.DisplayAlerts = False
MsgBox Target.Value
Target.Offset(1, 0).Select
End Sub

as before, the msgbox showed the Target value, but the protection
alert did not appear after I clicked OK.

Maybe you could do it that way with your cells locked and the sheet
protected.

Ken Johnson