Event procedure for change of a particular cell?

  • Thread starter Thread starter Chet
  • Start date Start date
C

Chet

Does anyone know of an event procedure (or code) that would enable a
piece of code to run upon the change of a particular cell on a
worksheet?

(I know there are event procedures for upon close, upon change, upon
calculate, etc but I only want to execute a piece of code when a
particular cell on my worksheet changes.).

Thanks,
Chet
 
The events you are looking for are in the individual sheets. The Open,
Close, etc. are in ThisWorkbook. Double-click the sheet you want, e.g.
"Sheet1" in the VBAProject-->Microsoft Excel Objects folder.
 
On the sheet you want to react to the event, right click the tab and select
View Code. Just above the code window are tow drop downs. Change the one on
the left to worksheet. The one on the right will now list all of the events
of the sheet. Select Change. Your code should end up something like this...

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$A$1" Then MsgBox "Tada"
End Sub
 
What is the change. Is the cell edited. Is it updated by a DDE formula. Is
it changed by a calculate occuring?

if by editing

right click on the sheet tab and select view code. then put in code like
this:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Target.Address = "$B$9" Then
MsgBox "B9 has changed"
End If
End If
End Sub

http://www.cpearson.com/excel/events.htm for an overview of events.
 
OK thanks. The change would be from editing the cell in question.
Thanks for the ideas..! Chet
 

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

Back
Top