ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Chart Object Model (https://www.excelbanter.com/excel-programming/324239-chart-object-model.html)

Joe Maki

Chart Object Model
 
I'm trying to programically (from VB) udate the column
lables on a chart. I can create the chart (daily values
for the week) which creates 5 columns. I need to access
the property that will let me label each column with the
respective day. If I modify an existing chart I can right
click on it, go to Source Data, then the Series tab and
supply the range in "Category (X) axis labels". I can't
seem to figure out what property/method this is in the
chart object model so I can dynaically assign these
values.

Tom Ogilvy

Chart Object Model
 
Turn on the macro recorder (tools=Macro=record a new macro) while you make
that change manually. Then turn it off and look at the recorded code. That
should give you a good start. I would expect the XValues property.

--
Regards,
Tom Ogilvy

"Joe Maki" wrote in message
...
I'm trying to programically (from VB) udate the column
lables on a chart. I can create the chart (daily values
for the week) which creates 5 columns. I need to access
the property that will let me label each column with the
respective day. If I modify an existing chart I can right
click on it, go to Source Data, then the Series tab and
supply the range in "Category (X) axis labels". I can't
seem to figure out what property/method this is in the
chart object model so I can dynaically assign these
values.




Shawn

Chart Object Model
 
"Joe Maki" wrote:

I'm trying to programically (from VB) udate the column
lables on a chart.


Try the XValues property of the SeriesCollection for the bars. Something like

ActiveChart.SeriesCollection(1).XValues = "=Sheet1!R1C1:R1C5"

Using the right series collection, of course. You can assign a Range or an
Array to the XValues property.

ActiveChart.SeriesCollection(1).XValues = _
Array("Tue", "Wed", "Thu", "Fri", "Sat")

Usually, you can record a macro to get the names of object properties like
this. What a recorded macro won't tell you are the quirks of properties like
XValues. For example, you can assign a Range or an Array to XValues, but
when you read it, you get an Array, regardless of how it was set. There's no
way, for example, to tell what Range has been assigned to XValues. But you
may not need that here.

--Shawn


No Name

Chart Object Model
 

ActiveChart.SeriesCollection(1).XValues = "=Sheet1!

R1C1:R1C5"

ActiveChart.SeriesCollection(1).XValues = _
Array("Tue", "Wed", "Thu", "Fri", "Sat")



I was able to get the array to work, not the range.
Thanks for the help, this at least makes it possible.


No Name

Chart Object Model
 

-----Original Message-----
Turn on the macro recorder (tools=Macro=record a new

macro) while you make

Great tip, I've never used macro recorder. Time to
experiment <g


All times are GMT +1. The time now is 05:46 PM.

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