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

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

LVL 1
gabrielPennybackReliability Business Tools Analyst IIAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Rory ArchibaldConnect With a Mentor Commented:
Use vbLf instead of chr(10)
0
 
SiddharthRoutCommented:
Try this

Separator:=chr(10)

Sid
0
 
gabrielPennybackReliability Business Tools Analyst IIAuthor Commented:
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
[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

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

Sid
0
 
gabrielPennybackReliability Business Tools Analyst IIAuthor Commented:
Awesome, Rory, thanks!
0
 
gabrielPennybackReliability Business Tools Analyst IIAuthor Commented:
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
All Courses

From novice to tech pro — start learning today.