VBA - Selecting certain charts and deleting data labels

Gtabtr1

New Member
Joined
Feb 15, 2017
Messages
39
Hi there,
I've searched and searched. Found bits and pieces but I'm struggling putting it all together. I have an Excel file where one worksheet contains 14 charts. I need the VBA code to select only 8 (a certain 8) and delete the data labels. I've found how to select only the ones I need but have not been able to remove all of the data labels at one time - or even loop through them and delete data labels one chart at a time. I would appreciate all the help I could get please.
Thank you
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
The following macro loops though each chart within the active sheet and removes the data label from each one. Change the name of the charts, accordingly.

Code:
Option Explicit

Sub RemoveDataLabelsFromEightCharts()


    Dim vChartNames As Variant
    Dim vChartName As Variant
    Dim wksChart As Worksheet
    
    Set wksChart = ActiveSheet
    
    vChartNames = Array("Chart 1", "Chart 2", "Chart 3", "Chart 4", "Chart 5", "Chart 6", "Chart 7", "Chart 8") 'change the chart names accordingly
    
    For Each vChartName In vChartNames
        wksChart.ChartObjects(vChartName).Chart.SetElement msoElementDataLabelNone
    Next vChartName
    
    MsgBox "Completed!", vbInformation
    
End Sub

Hope this helps!
 
Upvote 0

Forum statistics

Threads
1,215,840
Messages
6,127,215
Members
449,370
Latest member
kaiuuu

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