?
Solved

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

Posted on 2011-03-10
6
Medium Priority
?
360 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 85

Accepted Solution

by:
Rory Archibald earned 2000 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

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!

Question has a verified solution.

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

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

765 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