ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Detect when Active Cell Changes (https://www.excelbanter.com/excel-programming/280254-detect-when-active-cell-changes.html)

GarethG[_8_]

Detect when Active Cell Changes
 
I use the following code to update a chart in my worksheet:

Sub ChartRow()
Dim mySeries As Series
Dim myItem As PivotItem
Set mySeries =
ActiveSheet.ChartObjects("RowChart").Chart.SeriesC ollection(1)
Set myItem = ActiveCell.EntireRow.Cells(1).PivotItem
mySeries.Values = myItem.DataRange
mySeries.Name = myItem.LabelRange
End Sub

What I need is a way of detecting automatically whenever the active
cell has changed, then to execute this code.
The active cell may change by someone scrolling through records using
the cursor keys or by clicking directly with the mouse.

Anyone?
Gareth G



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/


David Hager[_2_]

Detect when Active Cell Changes
 
Use the Selection_Change event.

--
David Hager
Excel MVP

"GarethG" wrote in message
...
I use the following code to update a chart in my worksheet:

Sub ChartRow()
Dim mySeries As Series
Dim myItem As PivotItem
Set mySeries =
ActiveSheet.ChartObjects("RowChart").Chart.SeriesC ollection(1)
Set myItem = ActiveCell.EntireRow.Cells(1).PivotItem
mySeries.Values = myItem.DataRange
mySeries.Name = myItem.LabelRange
End Sub

What I need is a way of detecting automatically whenever the active
cell has changed, then to execute this code.
The active cell may change by someone scrolling through records using
the cursor keys or by clicking directly with the mouse.

Anyone?
Gareth G



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/





All times are GMT +1. The time now is 11:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com