Looking for Cell_Change Event

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

I have a worksheet that has several cells that users will
change. I am currently using the Private Sub
Worksheet_Change() function to activate the code. This
function runs the code anytime ANY CELL is modified.

I'm looking for a similar event funtion that only runs the
code when a certain cell is modified.

For instance, when A1 is changed I want the function Name
() to run. When A2 is changed I want the function Group()
to run. However, I don't want Name() to run when A2 is
changed or Group() to run when A1 is changed as would
happen using Worksheet_Change().

Any suggestions???
 
Hi Mike,

You're kind of out of luck with that, as there are no more specific Change
events. However, you can do a simple check in the Worksheet_Change event to
see which cell has changed:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, _
Range("A1")) Is Nothing Then
MsgBox "A1"
End If
If Not Application.Intersect(Target, _
Range("A2")) Is Nothing Then
MsgBox "A2"
End If
End Sub

The argument "Target" will contain a reference to the Range object that was
changed. This should execute pretty quickly, so I doubt you'll notice any
slowing due to it.
 
Back
Top