d4vem
08-15-2006, 07:02 AM
I have tried to find a solution to the following problem without much success.
I have an application that creates a number of charts each time it is run. What I need to do is delete any charts that currently exist from the previous time it was run. I could re name each new chart when it is created but I am not really bothered about the charts name I just want to delete any existing charts and let Excel default the name.
The code I have is;
Sub delete_charts()
Dim graph As Excel.Chart
For Each graph In ThisWorkbook.Charts
graph.Delete
Next
End Sub
It runs without erroring but fails to delete any existing charts
Any help would be much appreciated
I have an application that creates a number of charts each time it is run. What I need to do is delete any charts that currently exist from the previous time it was run. I could re name each new chart when it is created but I am not really bothered about the charts name I just want to delete any existing charts and let Excel default the name.
The code I have is;
Sub delete_charts()
Dim graph As Excel.Chart
For Each graph In ThisWorkbook.Charts
graph.Delete
Next
End Sub
It runs without erroring but fails to delete any existing charts
Any help would be much appreciated