Chart Series Name

hatman

Well-known Member
Joined
Apr 8, 2005
Messages
2,664
Based on a search of past posts, I came up with the following code snippet:

Code:
Charts("Current").SeriesCollection(1).Name = "=""" & headers(0, cnt) & """"

The problem is that although the syntax bailed out the person who originally posed the quastion, it is not helping me much... I keep getting an error that says "Unable to set the Name property of the Series Class."

What might I be doing wrong?
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
  • Do you have an array variable (or range object) named headers?
  • Do you have another variable named cnt?
  • What version of Excel are you using?
 
Upvote 0
Good questions:

1) Headers is a 2-dimensional array that exists in this procedure.
2) There is only one variable named cnt
3) I am using Excel 2000, and this procedure may need to run on Excel 2003.

A little more of the code follows:

Code:
qty = ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Row
    qty2 = ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Column
    
        
    Range("A3:A" & qty).Select
    ActiveSheet.Paste
    
    Application.Calculate
    
    Range(Cells(1, 1), Cells(qty, qty2)).Select
    
    Selection.Columns.AutoFit
    
    Range("a1").Select
    
    ReDim headers(2, qty2 - 4)
    
    For cnt = 5 To qty2
    
        headers(0, cnt - 5) = Cells(1, cnt).Value
        
        headers(1, cnt - 5) = "=Data!R2C" & cnt & ":R" & qty & "C" & cnt
    
    Next cnt
    
    x_rnge = "=Data!R2C1:R" & qty & "C1"
    
    For cnt = 0 To qty2 - 5
    
        headers(2, cnt) = True
    
        Select Case headers(0, cnt)
        
            Case "PSM_CURRENT_1"
                Charts("Current").SeriesCollection(1).XValues = headers(1, cnt)
                Charts("Current").SeriesCollection(1).Values = x_rnge
                Charts("Current").SeriesCollection(1).Name = "=""" & headers(0, cnt) & """"

Plus 175 other cases... if everything works properly, the correct range of data gets mapped to the correct data series... but this is going onto a CD and accompanying one of my colleagues to NASA on Monday where he will be doing live data downloads to troubleshoot system software for the Space Station... it NEEDS to have the belt-and-suspenders on it just in case something unexpected happens and I am not there to troubleshoot the data reduction.
 
Upvote 0
Can you check the object browswer in the VBE? Do you show a Series object as having a Values, XValues and Name properties? I'd've sworn that they didn't in XL2000, but were that the case your code should have bombed two lines sooner...
 
Upvote 0
Yes, I have a series object that does contain Values, Xvalues and Name.

In an attempt to come in through the back door on this one, I broke down and used the Record Macro to rename a series range... Here is the code that the Kernel recorded:

Code:
Sub Macro2()
'
' Macro2 Macro
' Macro recorded 11/11/2005 by Paul Sasur
'

'
    ActiveChart.SeriesCollection(1).Name = "=""PSM_CURRENT_Test"""
End Sub

I tried to execute just this one single line of code... and I got the same error message. I don't think I have EVER come across a recorded macro that bombed that BADLY before...
 
Upvote 0
I had to pull up a module where I was creating a chart. In my code I used the R1C1 address of the cells containing the names. Can you try that?

<font face=Courier New>            <SPAN style="color:#00007F">With</SPAN> .SeriesCollection(i)
                .XValues = "=" & rngSource.Address(True, True, xlR1C1, True)
                .Values = "=" & rngSource.Offset(, i).Address(True, True, xlR1C1, True)
                .Name = "=" & rngCurr.Cells(1, i + 1).Address(True, True, xlR1C1, True)</FONT>
 
Upvote 0

Forum statistics

Threads
1,214,533
Messages
6,120,076
Members
448,943
Latest member
sharmarick

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top