test to see if callout is on a graph

smak

New Member
Joined
Mar 18, 2022
Messages
33
Office Version
  1. 2010
Platform
  1. Windows
I have callouts on graphs. my full code will delete the existing one and add a new one.

but some of my starting graphs dont have existing call outs. this is causing an error in my code when I try to delete the existing callout (before I add the new one).

Please help me get the code right to delete the existing one if it exists...if it does not just go to the next step. I also tried iserror instead of the isempty but got errors on both

VBA Code:
If IsEmpty(ActiveChart.FullSeriesCollection(7).DataLabels.Select) = False Then
        ActiveChart.FullSeriesCollection(7).DataLabels.Select
        Selection.Delete
    End If
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
You should be able to use something like
Code:
If ActiveChart.FullSeriesCollection(7).HasDatalabels then ActiveChart.FullSeriesCollection(7).Datalabels.Delete
 
Upvote 0
it is not picking up when there is a data label. it seems to think that the charts dont have the label even though I can see it.
 
Upvote 0
I did not get the previously mentioned methods to work. but I did find a work around. I just let it see if there was an error on the "delete" command line. I understand there may be other ways to solve this but wanted to share my solution for anyone looking at the same issue.

On Error Resume Next
ActiveChart.FullSeriesCollection(7).DataLabels.Delete
 
Upvote 0
Solution

Forum statistics

Threads
1,215,409
Messages
6,124,743
Members
449,186
Latest member
HBryant

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