B
Barb Reinhardt
I'm trying to determine if a ChartObject is within the Print_Area on a given
worksheet and have this code. I've noted in the code where execution ends.
I've done a "debug.print" and see that the topleftcell is in the Print_area,
but I'm not sure why it's quitting on me. Does anyone have any ideas?
Dim ChtObj As Excel.ChartObject
Dim myRange As Range
myChartInRange = False
On Error Resume Next
Set myRange = myWS.Range("Print_Area")
On Error GoTo 0
If myRange Is Nothing Then Exit Sub
For Each ChtObj In myWS.ChartObjects
myChartInRange = False
'Execution in this sub ends on the line below
If Not Intersect(ChtObj.TopLeftCell, myRange) Is Nothing Then
Debug.Print "Top Left in Range", myWS.Name, ChtObj.Name
Set myChtObj = ChtObj
myChartInRange = True
Exit For
End If
Next ChtObj
Debug.Print
worksheet and have this code. I've noted in the code where execution ends.
I've done a "debug.print" and see that the topleftcell is in the Print_area,
but I'm not sure why it's quitting on me. Does anyone have any ideas?
Dim ChtObj As Excel.ChartObject
Dim myRange As Range
myChartInRange = False
On Error Resume Next
Set myRange = myWS.Range("Print_Area")
On Error GoTo 0
If myRange Is Nothing Then Exit Sub
For Each ChtObj In myWS.ChartObjects
myChartInRange = False
'Execution in this sub ends on the line below
If Not Intersect(ChtObj.TopLeftCell, myRange) Is Nothing Then
Debug.Print "Top Left in Range", myWS.Name, ChtObj.Name
Set myChtObj = ChtObj
myChartInRange = True
Exit For
End If
Next ChtObj
Debug.Print