View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson[_3_] Jim Thomlinson[_3_] is offline
external usenet poster
 
Posts: 983
Default Execute Events Based Upon Selected Cell

Target is the cell you just selected, so here is some code for you...

Option Explicit

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Select Case Target.Address
Case "$H$2"
Target.Value = "X"
Case "$I$2"
Target.Value = "X"
Case "$J$2"
Target.Value = "X"
End Select
End Sub

HTH

"D.Parker" wrote:

I am trying to program code to execute specific conditions if certain cells
are selected. I am working within my worksheet and with the
Worksheet_SelectionChange (ByVal Target As Excel.Range) subroutine. I have
tried using the AcitveCell.Address per the following example:

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)

If ActiveCell.Address = Range("H2") Then
'Range("H2").Value = "X"
End If

End Sub

What has generally happened through my numerous iterations is that the "X"
is never entered into the selected cell or any other cell for that matter.

The goal is to have "X" entered into cell H2 only if cell H2 is selected.
Your assistance is highly appreciated. Any advice or recommendations you may
have is again well appreciated.

Kind regards,

D.Parker