Solved

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

Posted on 2011-03-15
3
614 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

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

739 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