![]() |
Event procedure for change of a particular cell?
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 |
Event procedure for change of a particular cell?
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 -- HTH... Jim Thomlinson "Chet" wrote: 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 |
Event procedure for change of a particular cell?
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. "Chet" wrote: 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 |
Event procedure for change of a particular cell?
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. -- Regards, Tom Ogilvy "Chet" wrote: 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 |
Event procedure for change of a particular cell?
Just a heads up, but
Change < SelectionChange -- Regards, Tom Ogilvy "Jim Thomlinson" wrote: 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 -- HTH... Jim Thomlinson "Chet" wrote: 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 |
Event procedure for change of a particular cell?
OK thanks. The change would be from editing the cell in question.
Thanks for the ideas..! Chet |
All times are GMT +1. The time now is 11:45 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com