Solved

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

Posted on 2011-03-10
6
354 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
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 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 …

726 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