Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Changing Series Name

I have a macro which amoung other things changes the name and values of an
embedded chart. When I run the macro for the first time everything works as
intended. If I rerun the macro, an error occurs at the .name statement. If
I comment out that line, everything else works fine. The same thing happens
if I have saved the file (after the error has occured once), and then re-open
the file and try to run the macro. The error message is

Run time error '1004':
Unable to set the Name property of the series class

Once the error has occured, the macro will never work correctly again unless
I create a new chart, and change the chart name in the macro. If I do this
the macro will work once, and upon subsequent running of the macro, the .name
error will occur.

The section of the code involved is:

k=1
While stock(k) < ""
Sheets("Plot Period").Select
ActiveSheet.ChartObjects("Chart 14").Activate
With ActiveChart.SeriesCollection(k)
.Name = stock(k) 'this is the statement that causes the error
.XValues = "='" + stock(k) + "'!" + daterange
.Values = "='" + stock(k) + "'!" + gainrange
End With

k = k + 1

I have tried other forms of the code, with no success.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 129
Default Changing Series Name

Hi,

when the error occurs, does the series have any data?
if the series doesn't have enough data and no data point is displayed,
it seems impossible to handle the series completely from macro.
to display data points, you should set any appropriate data in
XValues and Values before Name property, or set chart options
temporarily like this:

ActiveChart.DisplayBlanksAs = xlZero
ActiveChart.PlotVisibleOnly = False

--
HTH,

okaizawa

AltshulerMG wrote:
I have a macro which amoung other things changes the name and values of an
embedded chart. When I run the macro for the first time everything works as
intended. If I rerun the macro, an error occurs at the .name statement. If
I comment out that line, everything else works fine. The same thing happens
if I have saved the file (after the error has occured once), and then re-open
the file and try to run the macro. The error message is

Run time error '1004':
Unable to set the Name property of the series class

Once the error has occured, the macro will never work correctly again unless
I create a new chart, and change the chart name in the macro. If I do this
the macro will work once, and upon subsequent running of the macro, the .name
error will occur.

The section of the code involved is:

k=1
While stock(k) < ""
Sheets("Plot Period").Select
ActiveSheet.ChartObjects("Chart 14").Activate
With ActiveChart.SeriesCollection(k)
.Name = stock(k) 'this is the statement that causes the error
.XValues = "='" + stock(k) + "'!" + daterange
.Values = "='" + stock(k) + "'!" + gainrange
End With

k = k + 1

I have tried other forms of the code, with no success.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Changing Series Name

There was data in the series (from the first time the macro ran) and I was
about to change the series values. You gave me a hint though, in other
macros I changed the series values first, and then the name, while this time,
I was changing the name first. Sure enough, when I moved the .name
instruction to the end, and did the .XValues and .Values first, the problem
went away. REALLY QUIRKY MICROSOFT!

Thanks very much for your response.

"okaizawa" wrote:

Hi,

when the error occurs, does the series have any data?
if the series doesn't have enough data and no data point is displayed,
it seems impossible to handle the series completely from macro.
to display data points, you should set any appropriate data in
XValues and Values before Name property, or set chart options
temporarily like this:

ActiveChart.DisplayBlanksAs = xlZero
ActiveChart.PlotVisibleOnly = False

--
HTH,

okaizawa

AltshulerMG wrote:
I have a macro which amoung other things changes the name and values of an
embedded chart. When I run the macro for the first time everything works as
intended. If I rerun the macro, an error occurs at the .name statement. If
I comment out that line, everything else works fine. The same thing happens
if I have saved the file (after the error has occured once), and then re-open
the file and try to run the macro. The error message is

Run time error '1004':
Unable to set the Name property of the series class

Once the error has occured, the macro will never work correctly again unless
I create a new chart, and change the chart name in the macro. If I do this
the macro will work once, and upon subsequent running of the macro, the .name
error will occur.

The section of the code involved is:

k=1
While stock(k) < ""
Sheets("Plot Period").Select
ActiveSheet.ChartObjects("Chart 14").Activate
With ActiveChart.SeriesCollection(k)
.Name = stock(k) 'this is the statement that causes the error
.XValues = "='" + stock(k) + "'!" + daterange
.Values = "='" + stock(k) + "'!" + gainrange
End With

k = k + 1

I have tried other forms of the code, with no success.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing "Series" Name jerry chapman Charts and Charting in Excel 3 April 23rd 23 11:45 AM
changing series value colors zasskar Charts and Charting in Excel 0 June 28th 06 11:13 PM
Changing series information for approximately 60 series in a workb Barb Reinhardt Charts and Charting in Excel 2 January 18th 06 10:22 PM
Changing Series Color Eli Kedar Charts and Charting in Excel 2 July 5th 05 09:43 AM
Quickly Changing Several Series to Appear the Same Barb Reinhardt Charts and Charting in Excel 2 February 7th 05 03:10 PM


All times are GMT +1. The time now is 11:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"