Solved

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

Posted on 2011-03-15
3
619 Views
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! :-)

Thanks,
John

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%"
            Else
              If ActiveChart.SeriesCollection(1).DataLabel = 1 Then
                ActiveChart.SeriesCollection(1).DataLabels.NumberFormat = "0%"
              Else
                ActiveChart.SeriesCollection(1).DataLabels.NumberFormat = "0.0%"
              End If
            End If
        Next

Open in new window

0
Comment
Question by:gabrielPennyback
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 24

Expert Comment

by:jimyX
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%"
...

or

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

or

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

Accepted Solution

by:
Saqib Husain, Syed earned 500 total points
ID: 35144936
Try

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

Author Closing Comment

by:gabrielPennyback
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.

Thanks,
- John
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

729 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