Deleting Textboxes from Charts

psmall

New Member
Joined
Mar 18, 2008
Messages
11
I have a macro that rescales 60 charts and adds in a historic date to a textbox in each chart. When I run the macro to update the sheet it over writes another textbox over the existing one (some now have 10+ as I didn't realise this was happening as I had the following at the start of the macro:

Dim oTextBox As TextBox
For Each oTextBox In ActiveSheet.TextBoxes
oTextBox.Delete
Next oTextBox

which I thought would delete all the textboxes.

What I need now, is a macro to loop through each chart and delete all the textboxes that are now there. So in essence it should be for each chart (say 1 to 60), delete all textboxes (say Textbox 1 to Textbox 12). Is this possible?
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
To delete all textboxes, regardless of their names, within each Chart object, try...

Code:
Dim ChrtObj As ChartObject

On Error Resume Next
For Each ChrtObj In ActiveSheet.ChartObjects
    ChrtObj.Chart.TextBoxes.Delete
Next ChrtObj
On Error GoTo 0

Hope this helps!
 
Upvote 0
Brilliant - that seems to work fine. Many thanks as I have taken ages with different methods to try and achieve this.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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