Ghost Charts

MrPogle

New Member
Joined
Dec 11, 2008
Messages
8
I am running Excel 2007 and Windows XP Professional. I had multiple charts in a worksheet and needed some as chart objects, each in their own tab, so I copied them to chart tabs. I then deleted the originals from the worksheet. I have some code that updates the charts in the worksheet but when I run this (what is below; this is not the actual code that does the updates, which works fine until it gets to a 'ghost' chart) to give me the names and positions of the charts:

Dim int_ChartCounter As Integer, str_ChartName As String
For int_ChartCounter = 1 To ActiveSheet.ChartObjects.Count
str_ChartName = ActiveSheet.ChartObjects(int_ChartCounter).Name & " - " & ActiveSheet.ChartObjects(int_ChartCounter).TopLeftCell.Address
Debug.Print str_ChartName
Next

it lists all the ones that are still there and the deleted ones like this:

Chart 255 - $R$392
Chart 256 - $R$392
Chart 257 - $R$392
Chart 258 - $U$399

None of them were called Chart 255 etc, they had meaningful names which have been replaced with Chart... When I look at the cell location (e.g. R392) there is nothing there. If I add:

If Left(str_ChartName, 5) = "Chart" Then
ActiveSheet.ChartObjects(int_ChartCounter).Activate
ActiveChart.Parent.Delete
End If

I get an application defined or object defined error.

I realize that I could modify my actual code with:

If Left(str_ChartName, 5) = "Chart" Then
don't run rest of code
Else
run rest of code
End If

but I fear this may lead to problems later. Any ideas?
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top