Solved

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

Posted on 2011-03-10
6
343 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
  • 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel Graph of User occurance 9 27
excel pivot question 4 40
Macro Capitalize 4 53
First Blank Cell in a range 7 34
Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

911 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now