Thread: On Exit Command
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default On Exit Command

Ben,

This worksheet event code will do it

Private Sub Worksheet_Change(ByVal Target As Range)

Application.EnableEvents = False
On Error GoTo ws_exit
If Not Intersect(Target, Range("A1")) Is Nothing Then
Range("myRange").Value = "n"
End If

ws_exit:

Application.EnableEvents = True
End Sub

This goes in the worksheet cfode module. You also need to define a named
ranmge called 'myRange' to cover the cells you want to change


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Ben" wrote in message
...
How do I set it a cell so that when a certain cell's
content has been changed other cells contents change.

For example I have 20 cells that either have a 'y'
or 'n'. These 'y', or 'n' values are input manually.

There is also one cell that contains a number that is
input manually.

I would like to set it so that the 20 cell's that contain
an 'y' or 'n' value are set to 'n' when the cell that has
a number in it is changed and only when it changes.

If this is not possible how about doing the same thing
when the cell is exited?

Thanks Ben