Re: Chart Deactivate Event of Class Firing but not sure why
Since this is an interesting problem I decided to investigate further. My investigations confirm my previous post.
I found that, not only is the Chart Deactivated by SpecialCells, but also by Find and by reading a cell's formula.
Like I said, assuming that an object's "Activated" disposition is not affected by other code is a big risk.
Below you can see print-out of the sequence of events.
I had an event handler in the worksheet selection change event and sometimes that fires also when the Chart deactivates, but not always.
It seems that if the result of the operation is Nothing then the Chart Deactivate Event fires but the Worksheet Selection Change does not.
11:09:08: Class1: myChartClass_Activate: R6C1
11:09:08: Module1: TestSpecialCells: Test SpecialCells xlVisible
Set r = ActiveSheet.Range(Cells(1, 1), Cells(22, 26)).SpecialCells(xlVisible)[/COLOR]
RESULT
11:09:08: Class1: myChartClass_Deactivate: R6C1
11:09:08: Sheet1: Worksheet_SelectionChange: R1C1:R5C26,R13C1:R22C26
11:09:08: Class1: myChartClass_Activate: R6C1
11:09:08: Module1: TestSpecialCells: SpecialCells xlVisible Tested
11:09:08: Module1: TestSpecialCells: Test xlCellTypeFormulas
Set r = ActiveSheet.Range(Cells(1, 1), Cells(22, 26)).SpecialCells(xlCellTypeFormulas)
RESULT
11:09:08: Class1: myChartClass_Deactivate: R6C1
11:09:08: Sheet1: Worksheet_SelectionChange: R1C1:R22C2,R1C26:R22C26
11:09:08: Class1: myChartClass_Activate: R6C1
11:09:08: Module1: TestSpecialCells: xlCellTypeFormulas Tested
11:09:08: Module1: TestSpecialCells: R1C1:R22C2,R1C26:R22C26
11:09:08: Module1: TestSpecialCells: Test Find
Set r = ActiveSheet.Range(Cells(1, 1), Cells(22, 26)).Find("Row()", LookIn:=xlFormulas)
RESULT
11:09:08: Class1: myChartClass_Deactivate: R6C1
11:09:08: Class1: myChartClass_Activate: R6C1
11:09:08: Module1: TestSpecialCells: Find Tested
11:09:08: Module1: TestSpecialCells: R2C1
11:09:08: Module1: TestSpecialCells: Test NumberFormat
x = ActiveSheet.Range(Cells(1, 1), Cells(22, 26)).Find("Row()", LookIn:=xlFormulas).NumberFormat
RESULT
11:09:08: Class1: myChartClass_Deactivate: R6C1
11:09:08: Class1: myChartClass_Activate: R6C1
11:09:08: Class1: myChartClass_Deactivate: R6C1
11:09:08: Class1: myChartClass_Activate: R6C1
11:09:08: Module1: TestSpecialCells: NumberFormat Tested
11:09:08: Module1: TestSpecialCells: General