Exxcel Chart Code throws 'Object doesn't support this property or method' error

Posted on 2011-03-15
Last Modified: 2012-05-11
In the code below,  how can I write this line so that it works: "If ActiveChart.SeriesCollection(1).DataLabel = 1 Then ..."   Right now it throws an 'Object doesn't support this property or method' error. I've tried a bunch of variations, but obviously not the right one! :-)


Dim dl As DataLabels
      Set dl = ActiveChart.SeriesCollection(1).DataLabels
        For i = 1 To dl.Count
            If dl.Count <= 3 Then
                ActiveChart.SeriesCollection(1).DataLabels.NumberFormat = "0.00%"
              If ActiveChart.SeriesCollection(1).DataLabel = 1 Then
                ActiveChart.SeriesCollection(1).DataLabels.NumberFormat = "0%"
                ActiveChart.SeriesCollection(1).DataLabels.NumberFormat = "0.0%"
              End If
            End If

Open in new window

Question by:gabrielPennyback
LVL 24

Expert Comment

ID: 35144719
VBA is not really my game, so I am not too sure about this, but here I am:

1. Why there is a loop, I do not see you are using the counter "i" anywhere?
2. Only to give you more options to try ;-)

For i = 1 To ActiveChart.SeriesCollection(1).Points.Count
  if ActiveChart.SeriesCollection(1).Points(i).DataLabel.Characters.Text = 1 then
    ActiveChart.SeriesCollection(1).Points.Item(i).DataLabel.NumberFormat =  "0%"


  if ActiveChart.SeriesCollection(1).Points(i).DataLabel.Text = 1 then


  if ActiveChart.SeriesCollection(1).values(i) = 1 Then
LVL 43

Accepted Solution

Saqib Husain, Syed earned 500 total points
ID: 35144936

If ActiveChart.SeriesCollection(1).DataLabels.Item(1).Text = 1 Then

Author Closing Comment

ID: 35149917
Thanks, ssaqibh.

jimyx, I thought I had your second solution working, but then I tried it 3 times again and it didn't work. Pls forgive me if it does in fact work.

- John

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
text replacement instead of two macros only one macro 2 22
Excel Automation VBA 19 38
Excel - find text within text? 1 25
Dynamic Filter ? 4 22
Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now