Unable to set the Name Property of the Series Class : Error '1004'

F

Francois

I have an application that builds automatic QC graphs from imported data from a user database (another excel file). This one row of data is then plotted on a graph with its specific upper and lower limit values
My problem is that the specific data changes depending on the type of data, each type has its own upper and lower limits. I can get the chart to import the type of data that I select in a combo box, and the limits values will then be grouped specifically. I get the error when I want to display the graph (the code below is part of what builds the graph) and change the names of the series to the specifc type data that I imported

Error '1004': Unable to set the Name Property of the Series Clas

Sheets("Calcs").Selec
Select Case SectionNumbe
Case 1 'TM (Total Moisture
coaldata = Sheets("Calcs").Range("B11:AF11"
UL = Sheets("Calcs").Range("B12:AF12"
LL = Sheets("Calcs").Range("B13:AF13"
Case 2 'C
coaldata = Worksheets("Calcs").Range("B14:AF14"
UL = Sheets("Calcs").Range("B15:AF15"
LL = Sheets("Calcs").Range("B16:AF16"
Case 3 'As
coaldata = Worksheets("Calcs").Range("B17:AF17"
UL = Sheets("Calcs").Range("B18:AF18"
LL = Sheets("Calcs").Range("B19:AF19"
Case 4 'V
coaldata = Worksheets("Calcs").Range("B20:AF20"
UL = Sheets("Calcs").Range("B21:AF21"
LL = Sheets("Calcs").Range("B22:AF22"
Case 5 'A
coaldata = Worksheets("Calcs").Range("B23:AF23"
UL = Sheets("Calcs").Range("B24:AF24"
LL = Sheets("Calcs").Range("B25:AF25"
BVal = Sheets("Calcs").Range("B26:AF26"

Sheets("Coal Graph").Selec
With ActiveChar
.HasTitle = Tru
.ChartTitle.Text = "QC GRAPH" & Chr(10) & QCType & Chr(10) & MonthTyp

If SectionNumber = 5 The
ActiveChart.SeriesCollection.NewSerie
ActiveChart.SeriesCollection(4).Values = Sheets("Calcs").Range("B26:AF26"
ActiveChart.SeriesCollection(4).Name = "BASE VALUE
Els
.SeriesCollection(1).Values = coaldat
.SeriesCollection(1).Name = "ACTUAL
.SeriesCollection(2).Values = U
.SeriesCollection(2).Name = "UPPER LIMIT
.SeriesCollection(3).Values = L
.SeriesCollection(3).Name = "LOWER LIMIT
If .SeriesCollection.Count = 4 The
.SeriesCollection(4).Delet
End I
End I
.SeriesCollection(1).Name = "ACTUAL
.SeriesCollection(1).Values = coaldat
.SeriesCollection(2).Name = "UPPER LIMIT
.SeriesCollection(2).Values = U
.SeriesCollection(3).Name = "LOWER LIMIT
.SeriesCollection(3).Values = L
End With
 
J

Jon Peltier

Francois -

Did the range you used to apply the series .Values contain any chartable
data? If the range only contained blanks, errors, or text, you cannot
select the series, and if you cannot select the series, VBA has
difficulties accessing it.

You don't need to select the series to make it work. In fact, code runs
faster if you don't waste time selecting objects. But it seems to me
that the ability to adjust a series in VBA correlates with the ability
to select the series.

If you're setting up the chart and waiting for the range to be
populated, you could try assigning the .Name before the .Values. Or you
could put a dummy value in a cell in the range, and delete the cell
after setting whatever you needed for that series. In a pinch, changing
the series to an Area type chart lets you work on it, then you can
change it back.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top