Thread: Help with Code
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Dan Hatola Dan Hatola is offline
external usenet poster
 
Posts: 42
Default Help with Code

If it is specific to one worksheet, you can put the code in that sheet module
in the editor. You probably want to put it under a worksheet_change event

Private Sub Worksheet_Change(ByVal Target As Range)

Cells.Locked = False
If Range("D1").Value = "Y" Then
Range("E1").Locked = True
End If
End Sub




"TimN" wrote:

Great idea.

Where do I put this code? Is it in the This Workbook module?
All the rest of my code I have driving message boxes, user forms ets. I'm
not sure how to work with this situation where the code just effects a cell
in the workbook.

"salut" wrote:

In a protected sheet you can only change the unlocked cells.
So try to protect this sheet first and then lock or unlock the cell "E1"
depends on the value in cell "D1".

Code would be

if range("D1")="Y" then
range("E1").locked=true
else
range("E1").locked=false
endif

"TimN" wrote:

FIRST.... Let me say thanks for all the help I have received. I am new to
this position and new to VBA and nobody at the company knows it so You all
have been a life saver for me!!!

Here is the question:

Can I write code so than in the worksheet If cell D1 has the value of "Y",
and the user tries to enter data in E1, the cell (E1) would be disabled from
any entries going in?

Thanks again!!!

TimN