Looking for Cell_Change Event

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???
 
J

Jake Marx

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top