vbacoder
Active Member
- Joined
- Jul 7, 2007
- Messages
- 354
Hi everyone,
I'm looking for a way to select all the charts (or only one) on a worksheet in VB using its title/label?
I have tried Charts("Title").select, but this has not worked. I have recorded a macro, and the code generated is as follows:
ActiveSheet.ChartObjects("Chart 68").Activate
ActiveChart.ChartArea.Select
Selection.Delete
The Chart 68 bit is because I created 67 earlier charts (and deleted them; the latest being number 68.
Is there any way of using a less specific chart reference in the statement:
ActiveSheet.ChartObjects("Chart 68").Activate - like using "Title" instead of "Chart 68" in the brackets? My requirement is quite straight forward, I want to select any previously created charts in the worksheet and delete these, before creating a new chart. Of course, I could keep the same chart and change the data to be plotted, but selecting and deleting is more useful in my case.
Many thanks,
vcoder
I'm looking for a way to select all the charts (or only one) on a worksheet in VB using its title/label?
I have tried Charts("Title").select, but this has not worked. I have recorded a macro, and the code generated is as follows:
ActiveSheet.ChartObjects("Chart 68").Activate
ActiveChart.ChartArea.Select
Selection.Delete
The Chart 68 bit is because I created 67 earlier charts (and deleted them; the latest being number 68.
Is there any way of using a less specific chart reference in the statement:
ActiveSheet.ChartObjects("Chart 68").Activate - like using "Title" instead of "Chart 68" in the brackets? My requirement is quite straight forward, I want to select any previously created charts in the worksheet and delete these, before creating a new chart. Of course, I could keep the same chart and change the data to be plotted, but selecting and deleting is more useful in my case.
Many thanks,
vcoder