Bar Chart Bug: Unable to get the Count Property of The DataLabels class

TheWildAfrican

Board Regular
Joined
Apr 23, 2013
Messages
70
Hello All:

I’m trying to clean up the bugs on a VBA code used for generating Monthly Graphical Report. I thought I’ve fixed all the bugs until the code stated breaking on the line below. The line looks good to me, but I get a Run-time error “-2147467259 (80004005)’: Unable to get the Count property of the DataLabels class. It’d be greatly appreciated if someone can help with this bug. Thanks for your anticipated help.

Please see the code below.


Set objChart = .ChartObjects.Add(200, Top, 400, 200).Chart 'left , Top , width , height
objChart.ChartType = xlColumnClustered
objChart.SetSourceData .Range(sRange.Address), xlColumns
objChart.SeriesCollection(1).XValues = sRange.Resize(, 1)
objChart.SeriesCollection(1).Values = sRange.Resize(, 1).Offset(, 1)
objChart.SeriesCollection(2).Delete
objChart.HasTitle = True
objChart.ChartTitle.Characters.Text = "Year of Manufacture"
objChart.Location WHERE:=xlLocationAsObject, Name:="Monthly Graphical Report"
objChart.HasLegend = False
objChart.ApplyDataLabels xlDataLabelsShowLabelAndPercent, , , , , True

objChart.SeriesCollection(1).DataLabels.Font.Size = 7

objChart.SeriesCollection(1).ApplyDataLabels AutoText:=True, LegendKey:= _
False, ShowSeriesName:=False, ShowCategoryName:=False, ShowValue:=False, _
ShowPercentage:=False, ShowBubbleSize:=False
objChart.PlotArea.ClearFormats
objChart.SeriesCollection(1).Interior.ColorIndex = 5
objChart.SeriesCollection(1).Interior.Pattern = xlSolid
objChart.ChartArea.Font.Size = 8
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Forum statistics

Threads
1,224,605
Messages
6,179,860
Members
452,948
Latest member
UsmanAli786

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