Solved

Can't set the Separator parameter on multiple charts with VBA

Posted on 2011-03-10
6
353 Views
Last Modified: 2012-05-11
The macro below successfully sets every parameter for the series collection except the Separator, at which it bugs and displays this error message: 'Object doesn't support this property or method'. Selecting the chr doesn't help.

I am able to set this parameter only if I specify the name of a single chart:
    ActiveSheet.ChartObjects("Chart_3").Activate
    ActiveChart.SeriesCollection(1).ApplyDataLabels AutoText:=True, _
        ShowSeriesName:=True, ShowValue:=True, Separator:="" & chr(10) & ""

Why won't the variable work? And how do I get it to work? I have a total of 11 charts.

Thanks,
John
Sub GetSeparator()
Dim chr As ChartObject, rng1 As Range
For Each chr In ActiveSheet.ChartObjects
 Set rng1 = Intersect([ChartRange3], chr.TopLeftCell)
  If Not rng1 Is Nothing Then
  'chr.Activate
    chr.Chart.SeriesCollection(1).ApplyDataLabels AutoText:=True, _
        ShowSeriesName:=True, ShowValue:=True, Separator:="" & chr(10) & ""
    chr.Chart.SeriesCollection(2).ApplyDataLabels AutoText:=True, _
        ShowSeriesName:=True, ShowValue:=True, Separator:="" & chr(10) & ""
   End If
Next
End Sub

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
  • 2
6 Comments
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 35101602
Try this

Separator:=chr(10)

Sid
0
 
LVL 1

Author Comment

by:gabrielPennyback
ID: 35104081
Hi Sid, thanks. I'm still getting the same error. It just doesn't seem to be willing to be manipulated by a variable. There's gotta be some way to do this other than writing 11 different routines naming each chart, no?

John
0
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 35104115
John, May I see ur workbook so that I can play around with it rather than creating a fresh sample.

Sid
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 85

Accepted Solution

by:
Rory Archibald earned 500 total points
ID: 35107243
Use vbLf instead of chr(10)
0
 
LVL 1

Author Comment

by:gabrielPennyback
ID: 35114356
Awesome, Rory, thanks!
0
 
LVL 1

Author Closing Comment

by:gabrielPennyback
ID: 35114374
I can never figure out why some of the stuff I get online is so arcane and complicated when it doesn't always have to be. Simple is beautiful!

- John
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

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.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
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.

734 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