ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help with this error message (https://www.excelbanter.com/excel-programming/390260-help-error-message.html)

matelot

Help with this error message
 
Hi,
I have a macro that update the seriescollection values based on a checkbox.
If it's true it calls the following code and false it replaces the inArray
to a range with "0" value.
inArray = Range("A2:D2").Value
ActiveChart.SeriesCollection(i).Values = array(inArray)
It worked at 1 point and now I get this error "Error 1004 - unable to set
the values property of the series class". So I convert the 2 dim array into 1
dim and assign the 1 dim array into Activechart.seriescollection.values. The
problem is that the first time it works fine but after that, I get the same
error message.
Pls help.


OssieMac

Help with this error message
 
When things like this occur intermittently, it is sometimes due to some other
action occurring. In this case, the first thing that you should check is that
the chart is in fact active because something else might be causing it to
loose the focus and then the ActiveChart part is no longer valid.

Regards,

OssieMac


"matelot" wrote:

Hi,
I have a macro that update the seriescollection values based on a checkbox.
If it's true it calls the following code and false it replaces the inArray
to a range with "0" value.
inArray = Range("A2:D2").Value
ActiveChart.SeriesCollection(i).Values = array(inArray)
It worked at 1 point and now I get this error "Error 1004 - unable to set
the values property of the series class". So I convert the 2 dim array into 1
dim and assign the 1 dim array into Activechart.seriescollection.values. The
problem is that the first time it works fine but after that, I get the same
error message.
Pls help.


Dave Peterson

Help with this error message
 
Since inArray is already an array, would this work?

ActiveChart.SeriesCollection(i).Values = inArray

(untested)


matelot wrote:

Hi,
I have a macro that update the seriescollection values based on a checkbox.
If it's true it calls the following code and false it replaces the inArray
to a range with "0" value.
inArray = Range("A2:D2").Value
ActiveChart.SeriesCollection(i).Values = array(inArray)
It worked at 1 point and now I get this error "Error 1004 - unable to set
the values property of the series class". So I convert the 2 dim array into 1
dim and assign the 1 dim array into Activechart.seriescollection.values. The
problem is that the first time it works fine but after that, I get the same
error message.
Pls help.


--

Dave Peterson

matelot

Help with this error message
 
Thanks for the reply. I tried both responses with having the chart active
right before the line Activechart.seriescollection(i).values = array(inArray)
and having just ...values=inArray. I still get the same error.
Even when debugging, I even manually activate the chart and it still gives
me the error message.
What I am trying to do is when a user unchecks the box, the line graph is
hidden (set to 0) and when it is checked, I reassign the series values back
to the array stored before it was set to 0.

can you give any other pointer? Thanks so much. You guys have been of great
help.

"Dave Peterson" wrote:

Since inArray is already an array, would this work?

ActiveChart.SeriesCollection(i).Values = inArray

(untested)


matelot wrote:

Hi,
I have a macro that update the seriescollection values based on a checkbox.
If it's true it calls the following code and false it replaces the inArray
to a range with "0" value.
inArray = Range("A2:D2").Value
ActiveChart.SeriesCollection(i).Values = array(inArray)
It worked at 1 point and now I get this error "Error 1004 - unable to set
the values property of the series class". So I convert the 2 dim array into 1
dim and assign the 1 dim array into Activechart.seriescollection.values. The
problem is that the first time it works fine but after that, I get the same
error message.
Pls help.


--

Dave Peterson


OssieMac

Help with this error message
 
You have really got me intrigued now since you say that it sometimes works.
How can you set a series collection in a chart to a variable which disappears
once the macro has finished running? I would have thought that it must always
be a range on a worksheet.

I think that you might have to find a way of saving the range and resetting
the source data range.

Regards,

OssieMac

"matelot" wrote:

Thanks for the reply. I tried both responses with having the chart active
right before the line Activechart.seriescollection(i).values = array(inArray)
and having just ...values=inArray. I still get the same error.
Even when debugging, I even manually activate the chart and it still gives
me the error message.
What I am trying to do is when a user unchecks the box, the line graph is
hidden (set to 0) and when it is checked, I reassign the series values back
to the array stored before it was set to 0.

can you give any other pointer? Thanks so much. You guys have been of great
help.

"Dave Peterson" wrote:

Since inArray is already an array, would this work?

ActiveChart.SeriesCollection(i).Values = inArray

(untested)


matelot wrote:

Hi,
I have a macro that update the seriescollection values based on a checkbox.
If it's true it calls the following code and false it replaces the inArray
to a range with "0" value.
inArray = Range("A2:D2").Value
ActiveChart.SeriesCollection(i).Values = array(inArray)
It worked at 1 point and now I get this error "Error 1004 - unable to set
the values property of the series class". So I convert the 2 dim array into 1
dim and assign the 1 dim array into Activechart.seriescollection.values. The
problem is that the first time it works fine but after that, I get the same
error message.
Pls help.


--

Dave Peterson


Dave Peterson

Help with this error message
 
I don't speak charts (.charting may be a better newsgroup to use to get the
attention of those Charting experts).

But why not just remove the series and add it back when you need it.

This worked in my simple testing.

Option Explicit
Sub testme()

Dim myRng As Range
Dim wks As Worksheet

Set wks = ActiveSheet

With wks
.Select
.Range("a1").Select 'in case the chart is selected
Set myRng = .Range("b1", .Cells(.Rows.Count, "B").End(xlUp))
.ChartObjects(1).Chart.SeriesCollection(2).Delete
.ChartObjects(1).Chart.SeriesCollection.Add Source:=myRng
End With

End Sub


matelot wrote:

Thanks for the reply. I tried both responses with having the chart active
right before the line Activechart.seriescollection(i).values = array(inArray)
and having just ...values=inArray. I still get the same error.
Even when debugging, I even manually activate the chart and it still gives
me the error message.
What I am trying to do is when a user unchecks the box, the line graph is
hidden (set to 0) and when it is checked, I reassign the series values back
to the array stored before it was set to 0.

can you give any other pointer? Thanks so much. You guys have been of great
help.

"Dave Peterson" wrote:

Since inArray is already an array, would this work?

ActiveChart.SeriesCollection(i).Values = inArray

(untested)


matelot wrote:

Hi,
I have a macro that update the seriescollection values based on a checkbox.
If it's true it calls the following code and false it replaces the inArray
to a range with "0" value.
inArray = Range("A2:D2").Value
ActiveChart.SeriesCollection(i).Values = array(inArray)
It worked at 1 point and now I get this error "Error 1004 - unable to set
the values property of the series class". So I convert the 2 dim array into 1
dim and assign the 1 dim array into Activechart.seriescollection.values. The
problem is that the first time it works fine but after that, I get the same
error message.
Pls help.


--

Dave Peterson


--

Dave Peterson

Dave Peterson

Help with this error message
 
I see you have posted a series of questions in .charting where you got some very
nice responses.

I'd continue to post in that .charting newsgroup for questions like these (if I
were you).

Dave Peterson wrote:

I don't speak charts (.charting may be a better newsgroup to use to get the
attention of those Charting experts).

But why not just remove the series and add it back when you need it.

This worked in my simple testing.

Option Explicit
Sub testme()

Dim myRng As Range
Dim wks As Worksheet

Set wks = ActiveSheet

With wks
.Select
.Range("a1").Select 'in case the chart is selected
Set myRng = .Range("b1", .Cells(.Rows.Count, "B").End(xlUp))
.ChartObjects(1).Chart.SeriesCollection(2).Delete
.ChartObjects(1).Chart.SeriesCollection.Add Source:=myRng
End With

End Sub

matelot wrote:

Thanks for the reply. I tried both responses with having the chart active
right before the line Activechart.seriescollection(i).values = array(inArray)
and having just ...values=inArray. I still get the same error.
Even when debugging, I even manually activate the chart and it still gives
me the error message.
What I am trying to do is when a user unchecks the box, the line graph is
hidden (set to 0) and when it is checked, I reassign the series values back
to the array stored before it was set to 0.

can you give any other pointer? Thanks so much. You guys have been of great
help.

"Dave Peterson" wrote:

Since inArray is already an array, would this work?

ActiveChart.SeriesCollection(i).Values = inArray

(untested)


matelot wrote:

Hi,
I have a macro that update the seriescollection values based on a checkbox.
If it's true it calls the following code and false it replaces the inArray
to a range with "0" value.
inArray = Range("A2:D2").Value
ActiveChart.SeriesCollection(i).Values = array(inArray)
It worked at 1 point and now I get this error "Error 1004 - unable to set
the values property of the series class". So I convert the 2 dim array into 1
dim and assign the 1 dim array into Activechart.seriescollection.values. The
problem is that the first time it works fine but after that, I get the same
error message.
Pls help.

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson


All times are GMT +1. The time now is 01:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com